How to use the getFixedT function from i18next

Find comprehensive JavaScript i18next.getFixedT code examples handpicked from public code repositorys.

40
41
42
43
44
45
46
                ns: namespaces,
                preload: languages,
        });

        require('../utils/Logger').ready(`${languages.length} language(s) have loaded. (${languages.join(', ')})`);
        return new Map(languages.map(item => [item, i18next.getFixedT(item)]));
};
fork icon325
star icon475
watch icon19

53
54
55
56
57
58
59
60
61
62

function updateAvailableLanguages() {
  Object.keys(languageResources).forEach((key) => {
    // for some reason, 'pt-br' was not working, use just pt instead
    const k = key.split('-')[0]
    languages[k] = i18next.getFixedT(k)('language-name')
  })

  state.translation = {
    t: i18next.t,
fork icon228
star icon0
watch icon62

+ 3 other calls in file

47
48
49
50
51
52
        await appReady;
        return i18next;
});

exports.i18n = i18next;
exports.translate = namespaces => namespaces ? i18next.getFixedT(null, namespaces) : i18next.t.bind(i18next);
fork icon61
star icon151
watch icon12

15
16
17
18
19
20
21
22
23
24
  }, 1000 * 60);
}

async sendReminder(doc) {
  const language = (doc.serverLang) || 'pt-BR';
  const t = i18next.getFixedT(language);

  if (doc.rememberInPv) {
    try {
      const user = await this.client.users.fetch(doc.id);
fork icon15
star icon0
watch icon0

18
19
20
21
22
23
24
25
26
27
})

const t = (key, options) => i18n.t(key, options)

const getFixedT = lang => {
  const t = i18n.getFixedT(lang)
  return t
}

module.exports = { i18n, t, getFixedT }
fork icon3
star icon10
watch icon7

128
129
130
131
132
133
134
135
136

  return this;
}

subjecti18n(subject, vars = {}) {
  this.meta.subject = i18next.getFixedT(this.lang)(
    ['subjects', subject].join(':'),
    vars,
  );
fork icon0
star icon3
watch icon5

24
25
26
27
28
29
30
31
32
33

async run(interaction){
    let client = this.client;
    
    let user_translation = await translations.get_lang(interaction.user);
    let locale = global.t = i18next.getFixedT(user_translation || 'pt-BR');
    
    if(interaction.isCommand()){
        let command =  client.commands2.get(interaction.commandName.toLowerCase());
        //if (!client.commands2.has(interaction.commandName.toLowerCase())) return;
fork icon0
star icon1
watch icon0

-4
-3
const i18next = require('i18next');
exports.t = i18next.getFixedT(null, 'metaquery');
fork icon0
star icon1
watch icon0