Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem of language #19

Open
JohnB7777 opened this issue Aug 1, 2017 · 6 comments
Open

Problem of language #19

JohnB7777 opened this issue Aug 1, 2017 · 6 comments

Comments

@JohnB7777
Copy link

Hello,

Thanks for your module but I have a little problem : I display the language in english with language: 'en' on the config file but, although it's working for the time ("in 4 minutes"...), it's not working for arrival which is still written in german.
Thanks for you help !

@goprojojo
Copy link

I have the same issue: How can I change the language. It's now in German (Ankunft).

@GHLasse
Copy link
Contributor

GHLasse commented Sep 24, 2017

"in 4 minutes" is using moment(depature).locale(this.config.language).fromNow();
whereas the word "arrival" is taken from the language file (en.json) using this.translate("ARRIVAL")

I am using the module in English language without problems but I haven't updated it in a long time :-D Still not sure why it doesn't work because the code looks fine. Can you try overwriting the language option "en" directly for the module? Can you try "sv" as well maybe?

@GHLasse
Copy link
Contributor

GHLasse commented Oct 5, 2017

I just updated my version of MMM-Localtransport (from 32 commits ago :-D) and English language works fine for me. Make sure to set

var config = {
    port: 8080,
    language: 'en',
...
   modules: [
       {
            module: 'MMM-LocalTransport',
...
        },
...
    ]
}

I didn't set any language specifically for the module itself, so this.config.language is taken from config.language

@pies666
Copy link

pies666 commented Jan 3, 2018

Hey,
I have the same problem. When I set global language to en everything is fine. However plenty of users (including me) are not native english and we use other global language (pl for me). Just like You said few words are taken in english from module itself but some of them are being taken from "global en" which is not en for us. Can we change, somehow, those few word to be being used just like others? As far as I see it's only few of them. Cheers,

@GHLasse
Copy link
Contributor

GHLasse commented Jan 20, 2018

@pies666 I just tested your set-up as

var config = {
    port: 8080,
    language: 'pl',
...
   modules: [
       {
            module: 'MMM-LocalTransport',
            config: {
                language: 'en',
                ...
            }
        },
...
    ]
}

and for me it returned a mix of English (for 'in 7 minutes') and German (for "Ankunft")
I then changed the order of the languages around in getTranslations so that 'en' is on top. That way the fall-back should always be english.

The question is what the expected behaviour would be.
Taking Polish as an example of a (to the system) unknown language, and German as a known language, then we (desire to) get the following output:

  1. global 'de', local 'de' or n/a -> uses 'de'
  2. global 'de', local 'pl' -> defaults to 'en' (or uses 'de' from global?)
  3. global 'pl', local 'pl' or n/a -> defaults to 'en'
  4. global 'pl', local 'de' -> uses to 'de'

probably the first thing is to decide if this is the desired behaviour.

I think for unknown languages we will instead get:

convertTime: function(seconds){
        var ans = moment.duration(seconds, 'seconds').locale(this.config.language).humanize();

to use local language if defined, otherwise global as long as known to locale function, otherwise en

if(this.config.displayWalkType === 'short'){
            ans = ans.replace(this.translate("MINUTE_PL"),this.translate("MINUTE_PS"));
            ans = ans.replace(this.translate("MINUTE_SL"),this.translate("MINUTE_SS"));
            ans = ans.replace(this.translate("SECOND_PL"),this.translate("SECOND_PS"));
        }

to use local language if defined, otherwise global as long as translation is provided with the module, otherwise en (prev de).
I don't think we can avoid this behaviour unless we check and overwrite the local language config at start.

I can't understand why it loaded 'de' when I provided local 'en' though. I will have to look into that.

P.S.: sorry for the long and not very structured response. But in a hurry now :-D

@GHLasse
Copy link
Contributor

GHLasse commented Jan 21, 2018

Ok, a summary of my previous thread:

| global | local | expected | actual  | easy fix | improved |
|  'de'  |  --   |   'de'   |  'de'   |   'de'   |   'de'   |
|  'de'  | 'de'  |   'de'   |  'de'   |   'de'   |   'de'   |
|  'pl'  | 'de'  |   'de'   |  'de'   |   'de'   |   'de'   |
|  'pl'  |  --   |   'en'   |'pl'/'de'| 'pl'/'en'|   'en'   |
|  'pl'  | 'pl'  |   'en'   |'pl'/'de'| 'pl'/'en'|   'en'   |
|  'de'  | 'pl'  |   'en'   |'pl'/'de'| 'pl'/'en'|   'en'   |

easy fix:
rearrange the order of languages in getTranslations
improved:
check this.config.language at start and if it's not in the array of known languages, replace it with english.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants