mozillahispano / openwapp

OpenWapp is a open client for a well-known mobile IM service
65 stars 33 forks source link

Removed old translation service and replaced with mozL10n localization #176

Closed stollr closed 8 years ago

stollr commented 8 years ago

As @Timmaks has suggested in #175 I have done some refactoring and removed the legacy translation service and all its usages.

Maybe you will wonder why I did this ugly thing in app/scripts/utils/language.js:

   return {
     getLanguage: function () {
-      if (window.navigator.language &&
-        global.localisation[window.navigator.language]) {
+      // TODO: we are comparing to 'en-US' until we find a way to get
+      // all available translations from l10n.js
+      if (window.navigator.language && 'en-US' === window.navigator.language) {
         return window.navigator.language;
       }
       else {

Well, as far as I understand this function should test if a translation is available for a given locale and return it. If there is no translation, the default locale 'en-US' is returned. But the global.localisation object did only have the key 'en-US', so my change is equivalent to the origin with the advantage that there is no dependency to the old service anymore.

I hope this explanation was clear :-)

stollr commented 8 years ago

I found one last usage of the legacy translation service and replaced it.

Timmaks commented 8 years ago

As far as i know we don't need to check if the translation is there, i think you can remove it totally. The mozget function does the check everytime it is called. If there is no translation it will show the default language (en-US)

I am not a coder so i can be wrong.....

Timmaks commented 8 years ago

I will do a local build with your changes this weekend en test it, thanks for your work!

willyaranda commented 8 years ago

Hi @naitsirch thanks for contributing to OpenWapp! I will review this :)

willyaranda commented 8 years ago

+1 from my side

Timmaks commented 8 years ago

thanks