• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

access to config language setting

Scheduled Pinned Locked Moved Development
24 Posts 5 Posters 11.2k Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Away
    sdetweil @justjim1220
    last edited by sdetweil Feb 12, 2019, 8:06 PM Feb 12, 2019, 8:05 PM

    @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 offsets

    if I copy those values to the calendar config block than they are accessible…

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    J 2 Replies Last reply Feb 12, 2019, 8:12 PM Reply Quote 0
    • J Offline
      justjim1220 Module Developer @sdetweil
      last edited by Feb 12, 2019, 8:12 PM

      @sdetweil

      All I can find is to put this in your js file:

      getTranslations: function() {
      	return {
      		en: "translations/en.json",
      		de: "translations/de.json"
      	}
      }
      

      "Life's Too Short To Dance With Ugly People"
      Jim Hallock - 1995

      1 Reply Last reply Reply Quote 0
      • J Offline
        justjim1220 Module Developer @sdetweil
        last edited by Feb 12, 2019, 8:20 PM

        @sdetweil

        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);
        }

        "Life's Too Short To Dance With Ugly People"
        Jim Hallock - 1995

        S 1 Reply Last reply Feb 12, 2019, 8:22 PM Reply Quote 0
        • S Away
          sdetweil @justjim1220
          last edited by sdetweil Feb 12, 2019, 8:24 PM Feb 12, 2019, 8:22 PM

          @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.language
          

          doesn’t exist in the calendar module… so the set locale will fail…

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          J 3 Replies Last reply Feb 12, 2019, 8:26 PM Reply Quote 1
          • J Offline
            justjim1220 Module Developer @sdetweil
            last edited by Feb 12, 2019, 8:26 PM

            @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"
                }
            },

            "Life's Too Short To Dance With Ugly People"
            Jim Hallock - 1995

            S 1 Reply Last reply Feb 12, 2019, 8:32 PM Reply Quote 0
            • J Offline
              justjim1220 Module Developer @sdetweil
              last edited by Feb 12, 2019, 8:31 PM

              @sdetweil

              you will also need to add this to your start section:

              / /Set locale.
              moment.updateLocale(config.language, this.getLocaleSpecification(config.timeZone));
              

              "Life's Too Short To Dance With Ugly People"
              Jim Hallock - 1995

              1 Reply Last reply Reply Quote 0
              • S Away
                sdetweil @justjim1220
                last edited by Feb 12, 2019, 8:32 PM

                @justjim1220 but I don’t want to duplicate the language config…

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                S 1 Reply Last reply Feb 12, 2019, 8:41 PM Reply Quote 1
                • S Offline
                  strawberry 3.141 Project Sponsor Module Developer @sdetweil
                  last edited by Feb 12, 2019, 8:41 PM

                  @sdetweil the global language is accessible like this config.language see example https://github.com/MichMich/MagicMirror/blob/master/modules/default/clock/clock.js#L49

                  Please create a github issue if you need help, so I can keep track

                  S 1 Reply Last reply Feb 12, 2019, 8:56 PM Reply Quote 1
                  • J Offline
                    justjim1220 Module Developer @sdetweil
                    last edited by Feb 12, 2019, 8:42 PM

                    @sdetweil

                    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"
                    	}
                        },
                    

                    "Life's Too Short To Dance With Ugly People"
                    Jim Hallock - 1995

                    1 Reply Last reply Reply Quote 0
                    • S Away
                      sdetweil @strawberry 3.141
                      last edited by Feb 12, 2019, 8:56 PM

                      @strawberry-3-141 cool, thanks

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      C 1 Reply Last reply Feb 13, 2019, 12:46 AM Reply Quote 1
                      • 1
                      • 2
                      • 3
                      • 2 / 3
                      2 / 3
                      • First post
                        11/24
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy