Unexpected language with date

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
janpep
Posts: 270
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Unexpected language with date

Post by janpep »

Hello,
I have been using Domoticz for quite a few years, but I am new here to the forum.
In my dzvents script I get the output of the requested full monthname in English, while I expected it in Dutch.
Before making the translation myself, I look for the cause of this. I hope someone can help me.

The documentation states: "mmmm -- full monthname(e.g September) language depends on locale."
The language settings in Domoticz and in OS are Dutch.

The command used to get the daynumber and full monthname of tomorrow gives me "15 March" instead of "15 Maart"

Code: Select all

domoticz.time.dateToDate(domoticz.time.rawDate, 'yyyy-mm-dd', 'dd mmmm', 86400 )
I wonder if this is a bug or caused by settings.

Environment:
I am running Domoticz under Ubuntu 22.04 (with the language setting Dutch) as a virtual machine on Synology DS718+.

See the locale setting I get in the Ubuntu terminal:

Code: Select all

Terminalprompt$ locale
LANG=nl_NL.UTF-8
LANGUAGE=
LC_CTYPE="nl_NL.UTF-8"
LC_NUMERIC="nl_NL.UTF-8"
LC_TIME="nl_NL.UTF-8"
LC_COLLATE="nl_NL.UTF-8"
LC_MONETARY="nl_NL.UTF-8"
LC_MESSAGES="nl_NL.UTF-8"
LC_PAPER="nl_NL.UTF-8"
LC_NAME="nl_NL.UTF-8"
LC_ADDRESS="nl_NL.UTF-8"
LC_TELEPHONE="nl_NL.UTF-8"
LC_MEASUREMENT="nl_NL.UTF-8"
LC_IDENTIFICATION="nl_NL.UTF-8"
LC_ALL=
The Full monthname is shown in Dutch.

Code: Select all

Terminalprompt$ date +%B
maart
User avatar
RonkA
Posts: 115
Joined: Tuesday 14 June 2022 12:57
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Harlingen
Contact:

Re: Unexpected language with date

Post by RonkA »

Not an expert but in Time.lua there is a function with a reference to 'locale' as stated in the wiki;

Code: Select all

	function self.localeMonths()
		local months =
		{
			january = 1, february = 2, march = 3, april = 4, may = 5, june = 6, july = 7, august = 8,
			september = 9, october = 10, november = 11, december = 12, jan = 1, feb = 2, mar = 3, apr = 4,
			jun = 6, jul = 7, aug = 8, sep = 9, oct = 10, nov = 11, dec = 12
		}
Don't know if it's dangerous to modify this part of the /runtime/ part to the desired language but it would be nice..
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
Kedi
Posts: 577
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Unexpected language with date

Post by Kedi »

When necessary I use this:

Code: Select all

local dL = {"Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag"}
local mL = {'Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'October', 'November', 'December'}

local NextDay = dz.time.makeTime(sTime)
local MesDate = dL[NextDay.wday]..', '..string.format("%02d", NextDay.day)..' '..mL[NextDay.month]..' '..tostring(NextDay.year)
Logic will get you from A to B. Imagination will take you everywhere.
janpep
Posts: 270
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Unexpected language with date

Post by janpep »

Thanks for your responses.
Because of the statement "language depends on locale", I expected that dzvent would take the value from the OS language that is set, but that doesn't seem to be the case. Confusing.
Since I don't want to get stuck in this, I will continue to do the translation locally for the time being.
Dz on Ubuntu VM on DS718+ behind FRITZ!Box.
EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; Sonoff USB-Dongle Plus-E; Zigbee2Mqtt; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest