MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    access to config language setting

    Development
    5
    24
    5007
    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
      sdetweil last edited by

      how do I get access to the overall MM language setting in config.js in my module? that value is not passed to each modules config

      Sam

      Create a working config
      How to add modules

      justjim1220 1 Reply Last reply Reply Quote 0
      • justjim1220
        justjim1220 Module Developer @sdetweil last edited by

        @sdetweil
        My best guess: "MagicMirror/translations/translations.js"

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

        S 1 Reply Last reply Reply Quote 0
        • S
          sdetweil @justjim1220 last edited by sdetweil

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

          Sam

          Create a working config
          How to add modules

          justjim1220 3 Replies Last reply Reply Quote 0
          • justjim1220
            justjim1220 Module Developer @sdetweil last edited by

            @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

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

            1 Reply Last reply Reply Quote 0
            • justjim1220
              justjim1220 Module Developer @sdetweil last edited by

              @sdetweil

              NVM, I just tried it and it di not work.

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

              1 Reply Last reply Reply Quote 0
              • justjim1220
                justjim1220 Module Developer @sdetweil last edited by

                @sdetweil

                Which calendar module are you referring to?

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

                S 1 Reply Last reply Reply Quote 0
                • S
                  sdetweil @justjim1220 last edited by sdetweil

                  @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

                  Create a working config
                  How to add modules

                  justjim1220 2 Replies Last reply Reply Quote 0
                  • justjim1220
                    justjim1220 Module Developer @sdetweil last edited by

                    @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
                    • justjim1220
                      justjim1220 Module Developer @sdetweil last edited by

                      @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 Reply Quote 0
                      • S
                        sdetweil @justjim1220 last edited by sdetweil

                        @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

                        Create a working config
                        How to add modules

                        justjim1220 3 Replies Last reply Reply Quote 1
                        • 1
                        • 2
                        • 3
                        • 1 / 3
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy