Is there a way that os.date() strings like month/weekday/year names can be automatically localized depending on the language set for either the system or Rainmeter?
For example os.date("%B",os.time()) returns the current full month name (eg: May) in English but what if a user has their system and Rainmeter language set to some other language?
In my testing it seems regardless of OS/Rainmeter language output strings remain English. Also tried os.setlocale("<locale>") but couldn't get anything to work.
It is currently October 9th, 2024, 4:07 pm
Localized os.date() date strings?
-
- Posts: 150
- Joined: August 16th, 2013, 12:47 pm
-
- Rainmeter Sage
- Posts: 2744
- Joined: March 23rd, 2015, 5:26 pm
Re: Localized os.date() date strings?
The Rainmeter implementation of Lua is English only. If you want localized names, you'll need to use Rainmeter's Time measure.Crest wrote: ↑May 9th, 2023, 4:56 pm Is there a way that os.date() strings like month/weekday/year names can be automatically localized depending on the language set for either the system or Rainmeter?
For example os.date("%B",os.time()) returns the current full month name (eg: May) in English but what if a user has their system and Rainmeter language set to some other language?
In my testing it seems regardless of OS/Rainmeter language output strings remain English. Also tried os.setlocale("<locale>") but couldn't get anything to work.
-
- Posts: 150
- Joined: August 16th, 2013, 12:47 pm
Re: Localized os.date() date strings?
I'm using the Lua for handling conditional date calculations so I suppose the flow would be have some Time measure in the skin then in the script change the measure's timestamp value then read back the measure's localized output for use in the script. Wouldn't be too bad to just have a measure just for this purpose I guess. Will have to test.SilverAzide wrote: ↑May 9th, 2023, 5:27 pm The Rainmeter implementation of Lua is English only. If you want localized names, you'll need to use Rainmeter's Time measure.
Edit: I notice in the Time measure's docs a TimeStampLocale option. Is that necessary to have the strings localized or will they be automatically if that is left unset, depending on the configured OS/Rainmeter language?
-
- Rainmeter Sage
- Posts: 8395
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Localized os.date() date strings?
From what I know, the TimeStampLocale is used if you want to SET time to a timestamp in a different language (e.g. you're Italian and you want to set the timestamp to, say, "sabato 26 dicembre 2015"). To GET time in a different language you'll have to use FormatLocale, which can take similar values (e.g. you're English or whatever your TimeStampLocale sets your input to be, but you want to get the output time in Italian, like "sabato 26 dicembre 2015"). See the code here for reference - feel free to add TimeStampLocale to it, IF you specify the timestamp in that language. Judging from the way FormatLocale is behaving, if left unset, TimeStampLocale will default to an English format.
-
- Rainmeter Sage
- Posts: 2744
- Joined: March 23rd, 2015, 5:26 pm
Re: Localized os.date() date strings?
Yincognito is correct. For the Lua, you don't need to do too much back and forth. Do whatever calcs you need in your Lua script and return the result as a numeric timestamp (a number). You should be able to do this with some inline Lua, as in:Crest wrote: ↑May 9th, 2023, 5:44 pm I'm using the Lua for handling conditional date calculations so I suppose the flow would be have some Time measure in the skin then in the script change the measure's timestamp value then read back the measure's localized output for use in the script. Wouldn't be too bad to just have a measure just for this purpose I guess. Will have to test.
Edit: I notice in the Time measure's docs a TimeStampLocale option. Is that necessary to have the strings localized or will they be automatically if that is left unset, depending on the configured OS/Rainmeter language?
Code: Select all
TimeStamp=([&YourLuaScriptMeasure:YourDateFunction()])
FormatLocale=Local