i18next / i18nextify

enables localization of any page with zero effort.
MIT License
61 stars 21 forks source link

Regional language loaded even with languageOnly #86

Closed marcelothomaz closed 4 years ago

marcelothomaz commented 5 years ago

Hi,

Even with the load:'languageOnly' option I keep getting missingKeys for en-US, es-AR, pt-BR and other regional versions;

My config:

   <script>
      window.i18nextify.init({
         whitelist: ['pt','es','en'],
         ns: 'blog',
         fallbackLng: 'pt',
         ignoreTags: ['SCRIPT','STYLE'],
         detection: {
            caches: false
         },
         load: 'languageOnly',

      })
   </script>

Sample errors:

i18next::backendConnector: loaded namespace blog for language en {Latest Posts: "Latest Posts", Home: "Home", Tag: "Tag", Author: "Author", Help: "Help"} i18nextify.min.js:1 i18next: languageChanged en-US i18nextify.min.js:1 i18next: initialized {debug: true, initImmediate: true, ns: Array(1), defaultNS: Array(1), fallbackLng: Array(1), …} i18nextify.min.js:1 i18next: virtualization took: 13ms i18nextify.min.js:1 i18next::translator: missingKey en-US translation Sunalizer Sunalizer i18nextify.min.js:1 i18next::translator: missingKey en-US translation La forma más fácil, rápida y segura de contratar su instalador solar. La forma más fácil, rápida y segura de contratar su instalador solar. i18nextify.min.js:1 i18next::translator: missingKey en-US translation Home Home i18nextify.min.js:1 i18next::translator: missingKey en-US translation Tag Tag i18nextify.min.js:1 i18next::translator: missingKey en-US translation Author Author

UPDATE: Current workaround is to put an array of the wanted languages in the load option, e.g.:

...
load: [ 'pt','es','en'],
...
jamuhl commented 5 years ago

load does not take an array. And it only avoids loading of those en-US files -> see the log output only en got loaded (loaded namespace blog for language en)

saveMissing normally sends to fallbackLng: https://www.i18next.com/overview/configuration-options#missing-keys (saveMissingTo option)

for i18nextify we have an extra missingKeyHandler: https://github.com/i18next/i18nextify/blob/master/src/missingHandler.js which outputs to console (debounced) as we have this handler there will be no saveMissing to backend: https://github.com/i18next/i18next/blob/master/src/Translator.js#L154

The warning you see comes from here: https://github.com/i18next/i18next/blob/master/src/Translator.js#L139 using the detected language (en-US in this case)

marcelothomaz commented 5 years ago

Thank you Jan,

Will load only avoid loading, not querying keys in the language?

Another confusion I see is that my language was set to pt-br with en as second, maybe because “en” was an exact match to something in the [‘en’,’pt’] whitelist, reason why it was chosen?

Please do let me know if this is not the proper channel for these discussions.

Best regards Em 19 de dez de 2018 16:21 -0200, Jan Mühlemann notifications@github.com escreveu:

load does not take an array. And it only avoids loading of those en-US files -> see the log output only en got loaded (loaded namespace blog for language en)

saveMissing normally sends to fallbackLng: https://www.i18next.com/overview/configuration-options#missing-keys (saveMissingTo option)

for i18nextify we have an extra missingKeyHandler: https://github.com/i18next/i18nextify/blob/master/src/missingHandler.js which outputs to console (debounced) as we have this handler there will be no saveMissing to backend: https://github.com/i18next/i18next/blob/master/src/Translator.js#L154

The warning you see comes from here: https://github.com/i18next/i18next/blob/master/src/Translator.js#L139 using the detected language (en-US in this case)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/i18next/i18nextify/issues/86#issuecomment-448695257, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANDEvA7wFlO58eTv230aS8NPlCgNAd22ks5u6oO8gaJpZM4ZaqvJ.

jamuhl commented 5 years ago

It will avoid "querying" -> i18next.language will be just what was detected as preferred - while i18next.languages will be an array of languages used for querying in right order.

order should in your case always be something like:

userlang en-US: [en, pt] userlang pt-BR: [pt] userlang es-ES: [es, pt]

what you mean by proper channel - this is free software - so there won't be a support helping you ;) -> stackoverflow would be the right place for questions - the issues here for things that might be wrong.

Using our https://locize.com you would get professional support as a paying customer...