Open JohnB7777 opened 7 years ago
I have the same issue: How can I change the language. It's now in German (Ankunft).
"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?
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
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,
@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
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.
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 !