How to use the t function from i18next
Find comprehensive JavaScript i18next.t code examples handpicked from public code repositorys.
8 9 10 11 12 13 14 15 16 17
validate(val, msg, arg) { const lng = msg.client.translator.resolveLanguage(msg); const int = Number.parseInt(val); if(Number.isNaN(int)) return false; if(arg.oneOf && !arg.oneOf.includes(int)) { return i18next.t('argument_type.integer.available_options', { lng, options: arg.oneOf.map(opt => `\`${opt}\``) .join(', ') });
260
0
1
+ 5 other calls in file
161 162 163 164 165 166 167 168 169 170
}, { type: 'separator', }, { label: i18next.t('Toggle Developer Tools'), role: 'toggleDevTools', visible: false, }, {
66
94
6
+ 62 other calls in file
27 28 29 30 31 32 33 34
.serveMissingKeyRoute(app) .serveChangeKeyRoute(app) .serveRemoveKeyRoute(app) //Helper app.locals.t = i18n.t }
10
0
3
112 113 114 115 116 117 118 119 120 121
parametersArray.forEach(function(parameter, index) { parametersObject[index + 1] = parameter; }); } return i18next.t(messageID, parametersObject); }; i18n.getLanguagesAvailables = function() { return languagesAvailables;
6
46
6
68 69 70 71 72 73 74 75 76 77
} private getServiceQuickPickItems(withAnonym: boolean = false): Array<ServiceQuickPick> { let services = [ { label: i18next.t("pastebin.service"), description: "", service: new pastebin.pastebin(false) }, { label: i18next.t("github.service"),
13
33
8
+ 9 other calls in file
GitHub: hubot-js/hubot.js
23 24 25 26 27 28 29 30 31 32
i18n.use(backend) .init(initOptions); function t(key, vars) { if (isNaN(key) && i18n.exists(key)) { return vars ? i18n.t(key, vars) : i18n.t(key); } return key; }
3
22
3
GitHub: lavgup/Wiki-Utilities
3 4 5 6 7 8 9 10 11 12
class DeleteCommand extends Command { constructor() { super('delete', { aliases: ['delete', 'del', 'delet'], description: i18n.t('commands.delete.description', { returnObjects: true }), category: 'wiki', channel: 'guild', args: [ {
5
3
2
+ 3 other calls in file
28 29 30 31 32 33 34 35 36 37
translation.addTranslations(translations, 'de', 'DE') var suite = new Benchmark.Suite() suite .add('i18next', () => { return i18next.t('test.title', { lng: 'de', count: 1 }) })
0
2
2
22 23 24 25 26 27 28 29 30 31
message += i18next.t('statusMessages.paused') + ' - ' + i18next.t('statusMessages.resuming') + ' ' + Utils.formatTimeIn(this.timeLeft, this.settings.get('language')) return message } else { message += i18next.t('statusMessages.paused') + ' ' + i18next.t('statusMessages.indefinitely') return message } }
404
0
34
+ 27 other calls in file
GitHub: 4gray/compodoc
82 83 84 85 86 87 88 89 90 91
} }); } public translate(key: string): string { return i18next.t(key); } public supportLanguage(language: string): boolean { return typeof this.availablesLanguages[language] !== 'undefined';
383
0
2
34 35 36 37 38 39 40 41 42 43
var createParameterFromType = function (type, options) { var Constructor = mapping[type]; if (!defined(Constructor)) { throw new TerriaError({ title: i18next.t("models.createParameter.unsupportedErrorTitle"), message: i18next.t("models.createParameter.unsupportedErrorMessage", { type: type }) }); }
331
986
0
15 16 17 18 19 20 21 22 23 24
var createCatalogMemberFromType = function (type, terria) { var Constructor = mapping[type]; if (!defined(Constructor)) { throw new TerriaError({ title: i18next.t("models.catalog.unsupportedTypeTitle"), message: i18next.t("models.catalog.unsupportedTypeMessage", { type }) }); }
331
986
0
15 16 17 18 19 20 21 22 23 24
debug: false, // turn on for debugging nsSeparator: '.', keySeparator: ':', }) const t = (key, options) => i18n.t(key, options) const getFixedT = lang => { const t = i18n.getFixedT(lang) return t
3
10
7
79 80 81 82 83 84 85 86 87 88
toPhoneNumbers: client.responderPhoneNumbers, fromPhoneNumber: location.phoneNumber, responderPushId: client.responderPushId, deviceName: location.displayName, alertType: newSession.alertType, message: t('alertStart', { lng: client.language, alertTypeDisplayName, deviceDisplayName: location.displayName }), reminderTimeoutMillis: client.reminderTimeout * 1000, fallbackTimeoutMillis: client.fallbackTimeout * 1000, reminderMessage: t('alertReminder', { lng: client.language, deviceDisplayName: location.displayName }), fallbackMessage: t('alertFallback', { lng: client.language, deviceDisplayName: location.displayName }),
2
1
6
+ 199 other calls in file
29 30 31 32 33 34 35 36 37 38
var url = defaultValue( options.url, this.terria.configParameters.gnafSearchUrl ); this.name = i18next.t("viewModels.searchAddresses"); this.gnafApi = defaultValue( options.gnafApi, new GnafApi(this.terria.corsProxy, url) );
1
0
0
+ 2 other calls in file
47 48 49 50 51 52 53 54 55 56
var suburbs = tableStructure.getColumnWithName( i18next.t("map.gnafAddressGeocoder.suburb") ); smooshColumn(addressesCol, suburbs); var state = tableStructure.getColumnWithName( i18next.t("map.gnafAddressGeocoder.state") ); smooshColumn(addressesCol, state); var postCodeCol = tableStructure.getColumnWithName( i18next.t("map.gnafAddressGeocoder.postcode")
1
0
0
+ 6 other calls in file
97 98 99 100 101 102 103 104 105 106
resources: require('./i18n'), returnObjects: true }); localizationClient.localize = function localize() { const args = arguments; const value = i18n.t(...args); if (Array.isArray(value)) return value[Math.floor(Math.random() * value.length)]; return value; };
0
1
0
GitHub: mifi/lossless-cut
127 128 129 130 131 132 133 134 135 136
if (!askBeforeClose) return; const choice = electron.dialog.showMessageBoxSync(mainWindow, { type: 'question', buttons: ['Yes', 'No'], title: i18n.t('Confirm quit'), message: i18n.t('Are you sure you want to quit?'), }); if (choice === 1) { e.preventDefault();
909
0
195
216 217 218 219 220 221 222 223 224 225
{ name: '\u200b', value: '\u200b' }, { name: i18next.t('monthprotector'), value: json.protector.description_fr } ) }
1
1
1
+ 735 other calls in file
GitHub: maxhuse/helpdesk-rrn
72 73 74 75 76 77 78 79 80 81
const newStaffId = newStaff[0]; // In the first element of response is ID of new staff if (newStaffId === 0 || newStaffId === undefined) { logger.log('error', i18next.t('server.invalid_staff_id')); } const responseFields = { id: newStaffId,
1
1
2
+ 2 other calls in file