Read the statement by Michael Teeuw here.
access to config language setting
-
@sdetweil
My best guess:"MagicMirror/translations/translations.js" -
@justjim1220 no… that is available translations… I mean the value in config.js
port: 8086, ipWhitelist: [], // Set [] to allow all IP addresses // or add a specific IPv4 of 192.168.1.5 : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"], // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"], language: "en", < ------------ this value timeFormat: 12, timezone: "Europe/Oslo", units: "imperial",the calendar code uses this value, BUT doesn’t get it config.language is not set (cause config comes from the module block)
-
@sdetweil
from what I can tell, modules containing the ability to change the language have their own translations folder.Other than that, have you tried
language = this.language -
NVM, I just tried it and it di not work.
-
Which calendar module are you referring to?
-
@justjim1220 the default calendar module
the code in calendar.js does
// Set locale. moment.updateLocale(this.config.language, this.getLocaleSpecification(this.config.timeFormat));but it doesn’t have any value for this.config.language
as language is not in the MODULE config…
I also want to set timezone… as the user I am helping cannot get the clock and calendar to sync time offsetsif I copy those values to the calendar config block than they are accessible…
-
All I can find is to put this in your js file:
getTranslations: function() { return { en: "translations/en.json", de: "translations/de.json" } } -
for timezone:
Add this to your defaults in the modules js:timezone: "America/Chicago"Then add this in the code:
getScripts: function() { return [ "moment.js", "moment-timezone.js" ]; },and this:
var now = moment(); if (this.config.timezone) { now.tz(this.config.timezone); } -
@justjim1220 no… you are not understanding me…
how do i get the USERS config for language and timezone? not system time, etc…
user is in Norway…
this.config.languagedoesn’t exist in the calendar module… so the set locale will fail…
-
@sdetweil after you add all that I posted, in your config file the use can add the timezone and language they want to use.
{ module: "calendar", position: "top_left", config: { language: "en", timezone: "Norway/Oslo" } }, -
you will also need to add this to your start section:
/ /Set locale. moment.updateLocale(config.language, this.getLocaleSpecification(config.timeZone)); -
@justjim1220 but I don’t want to duplicate the language config…
-
@sdetweil the global language is accessible like this
config.languagesee example https://github.com/MichMich/MagicMirror/blob/master/modules/default/clock/clock.js#L49 -
I just did added this to the calendar config and it changed it automatically:
{ module: "calendar", position: "top_left", // This can be any of the regions. Best results in left or right regions. config: { language: "fr", timezone: "France/Paris" } }, -
@strawberry-3-141 cool, thanks
-
@sdetweil said in access to config language setting:
@strawberry-3-141 cool, thanks
The kid knows his stuff! He’s a good guy! Matter of fact he gave me this to add to my module if it’s of any help :)
I use this under the start: function()
this.config.lang = this.config.lang || config.language; //automatically overrides and sets language :) this.config.units = this.config.units || config.units; -
Sorry for necroing this post, but from all I’ve read so far, this came up with most relevant information and solutions.
My question is this - is there a reason why the language change via config was never incorporated in this module?
-
@justbob what module? this was a general question, not tied to any module
-
@sdetweil You mentioned default calendar module, and there were talks about default clock, so my questions referred to those…
-
@justbob what do you mean language change?
the modules use the default translations
set by changing language line 33 of the config.js.sample
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login