Date format localisation

Hi, I’m using WFS 1.5.7 beta to create my first watch face on my Galaxy Watch6 Classic.

I’d like to add a Date component that looks like this:

Thu, 24 August

But where the formatting of the date will change based on the device language.

For example: on my Galaxy S23, if I change the phone’s language to English (United Kingdom), then the lockscreen date says Thu, 24 August.

But if I change the phone’s language to English (United States), then the lockscreen date says Thu, August 24.

So I want the date of my watch face to behave the same way, ie. changing its format based on the watch’s device language (which is itself synced from my phone).

Is this possible?

Hello,
Could you please try to add tags instead of Digital clock date? May be tags will work as you expect.

Here is a way to “sneak it” because the US is not on 24 hour time
Create two text boxes and group them together then move and size them to what you want

First one tag is for most of the world that uses 24 hour time and Day Month Year format
[DAY_WEEK_S], [DAY_1_31_Z] [MON_S]
for the color opacity use this tag (be sure to remove the default 100% so it is only the tag)
[IS_24H] ? 100 : 0

Second one use US Time
[DAY_WEEK_S], [MON_S] [DAY_1_31_Z]
and opacity is [IS_24H] ? 0 : 100

That way if you are in the US which is one of the few countries that uses Month Day Year format

It isn’t perfect.

Ron
Ron Samsung Developer Relations

1 Like

I know the answer to your problem.

The Language location tags exist. They’re just not shown in the WFS documentation. They are the same as Galaxy Watch Studio for Tizen.

  1. So say, for Thu, August 24.
    This is for US language, right?!

If that’s the case, put your default opacity at 100.
Then in the Opacity Tag, write this:

([LANG_LOC]==“en_UK”)*-100

This formula means that this date’s opacity will be at zero, when the language location is set to English(UK).

  1. For your UK Date: Thu, 24 August

Default Opacity at Zero. Write the next formula in its Opacity Tag:
([LANG_LOC]==“en_UK”)*100.

When English UK is chosen, the opacity will be at 100 and will be shown.

1 Like

Hi, thanks for the helpful answer! I wasn’t aware of the LANG_LOC tag but it looks like it should do the trick.

As I understand it, your solution means that I need to have two separate date components, right? One formatted the US way, and the other formatted the UK way, and then I use the tag for each one to set its respective opacity?

Won’t that result in additional battery drain though, to have two date components instead of just one?

I guess there’s no way to achieve this with just a single date component. :slight_smile:

Hi Ron, thanks for the suggestion. Unfortunately a solution based on 24 vs 12 hour time, wouldn’t really solve my goal, because although the USA is the only country in the world that uses MM-DD-YY, it is not the only country that uses 12 hour time.

There are other countries that use the international DD-MM-YY format, but also use 12 hour time - such as New Zealand, Australia, and the United Kingdom.

Plus, on Samsung smartphones (such as my Galaxy S23), there is a separate setting for “Use 24-hour format” found under Settings > General Management > Date and Time, which is independant of the device language setting.

So I need a solution that is based on the device’s language setting, not based on whether a 12 hour clock is used.

Is there any reason why WFS doesn’t have a native solution for showing the date using the device’s language format? Or is there a plan to add this in the future? After all, Android itself natively supports this functionality on smartphones, so why not the watch?

Hi again, I’ve been playing around with ternary operators, as documented at the bottom of this page:

In theory, I should be able to use a ternary operator inside a single date or text field, using [LANG_LOC]==“en_US” as the conditional_operation, and output either the USA or non-USA date format based on this conditional. This would mean I can have just one date/text field, instead of needing two of them and manipulating the opacity of each one.

There’s also another post here: Using ternary operators in text field – which confirms that ternary operators should work inside a text field.

However, I’m stuck with this and I wonder if I’ve encountered a bug.

For example, this works correctly:

(([LANG_LOC]==“en_US”) ? “USA” : “Not USA”)

And so does this, using a single tag for the “result_if_true” result:

(([LANG_LOC]==“en_US”) ? [MON_F] : “Not USA”)

But if I try to add more than one tag for the “result_if_true” or “result_is_false”, then it doesn’t work and just outputs the entire ternary operator:

(([LANG_LOC]==“en_US”) ? ([DAY_WEEK_S], [MON_F] [DAY_1_31]) : “Not USA”)

I’ve tried using various combinations of parentheses around the tags, but I can’t get it to work if there is more than one tag in the result.

Can you get it to work? Any ideas?

you are missing the second ?
see Ternary Operator in the tutorial for Opeations

Ron
Samsung Developer Relations

Hi Ron, I’m not sure what you mean. There is only one question mark in a ternary operation, per the documentation at Tag expressions | Samsung Developers

A ternary operation looks like this:

conditional_operation? result_if_true: result_if_false

So there are three components: the conditional_operation, the result_if_true and the result_if_false.

I’ll break down the operation that I’m trying to use:

  • conditional_operation = ([LANG_LOC]==“en_US”)
  • result_if_true = ([DAY_WEEK_S], [MON_F] [DAY_1_31]) → this is not a nested ternary operation
  • result_if_false = “Not USA”

The operation works when I use a single tag for the result_if_true, but if I use more than one tag - as I’m doing above - then it doesn’t work.

Is this a bug?

Based on this Date format by country - Wikipedia, I use tag expressions like this for the US/UK and another some countries date format.

[DAY_WEEK_S], (([LANG_LOC]=='en_US')+([LANG_LOC]=='en_CA')+([LANG_LOC]=='en_ZA')+([LANG_LOC]=='ko_KR')+([LANG_LOC]=='ja_JP')?[MON_F]:[DAY_1_31]) (([LANG_LOC]=='en_US')+([LANG_LOC]=='en_CA')+([LANG_LOC]=='en_ZA')+([LANG_LOC]=='ko_KR')+([LANG_LOC]=='ja_JP')?[DAY_1_31]:[MON_F])
1 Like

Right I didn’t look close enough and thought you were doing a nested conditional because of the second tag.

And this looks like a bug to me as @ZNW pointed out only one tag in the result works if you put 2 in it then it doesn’t parse right.

I’ll report it as a bug but @ZNW has the solution.

Ron

1 Like

For some reason I can’t get your tag expression to work on my watch (Galaxy Watch 6 Classic).

I’ve copied it verbatim into the Text Field part of my Date component, and when I change the language in the Run panel inside WFS, then the date format changes correctly in the Run panel’s preview.

But when I push the watch face to my watch, and then change the language on my phone, it doesn’t change the format on the watch.

I’ve also tried reducing it down to the following for simplicity, but no luck:

[DAY_WEEK_S], (([LANG_LOC]==‘en_US’) ? [MON_F] : [DAY_1_31]) (([LANG_LOC]==‘en_US’) ? [DAY_1_31] : [MON_F])

Can you confirm if your tag expression actually works for you on your watch? And which watch do you have?

FYI @ZNW and @r.liechty_SDR - I’ve finally solved this!

Turns out you have to use double-quotes around the language, not single quotes.

ZNW’s answer above contained this:

([LANG_LOC]=='en_US')

But it needs to be written like this:

([LANG_LOC]=="en_US")

So here is the final string that I’m now using, which I’ve tested on my Galaxy Watch6 (Wear OS 4) and confirmed it’s working correctly:

([DAY_WEEK_S]), (([LANG_LOC]=="en_US")+([LANG_LOC]=="en_CA") ? [MON_F] : [DAY_1_31]) (([LANG_LOC]=="en_US")+([LANG_LOC]=="en_CA") ? [DAY_1_31] : [MON_F])

Using the above string, if the phone’s language is set to either “English (United States)” or “English (Canada)”, then the watch will show the date as:

Wed, November 1

And if the phone’s language is anything else, then the watch will show the date as:

Wed, 1 November

Thus, the watch always matches the phone. I’ve only used US and Canadian English in my string because AFAIK they are the only two countries that use the Month/Day format on Android, rather than Day/Month.

2 Likes