Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale can be longer than just 2 letter code #86

Open
Crystal-RainSlide opened this issue Mar 3, 2022 · 7 comments
Open

locale can be longer than just 2 letter code #86

Crystal-RainSlide opened this issue Mar 3, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@Crystal-RainSlide
Copy link

For this assertion:

assert len(locale_set) == 2, "locale must be a 2 letter code, see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes"

...and the way locale is used:


"date": format_date(loc_revision_date, format="long", locale=locale),

...and the document of Babel and timeago:

Instead of just 2 letter code, locale also support longer format like en_US, or even:

This assertion should be lifted, and document of this plugin may be changed accordingly, from ISO 639-1 to the document of Babel and timeago.


Change locale to locale: { default: en, babel: en_US, timeago: en_short } or:

locale: en
locale_babel: en_US
locale_timeago: en_short

... may also be considered.

@timvink
Copy link
Owner

timvink commented Mar 4, 2022

Thanks for reporting this. I agree we should support this, using a 2-letter locale is an unnecessary simplification.

I'm thinking of writing a kind of validation function, that depending on the type validates the locale input. I would like to throw a helpful error message when a user has invalid input.

Separate locale input is also something to be considered. Great for developers that want to use multiple time formats in a theme, but also additional cognitive overhead for regular users.

Will give it some thought next time I work on this plugin. In the meantime I could remove the assertion if that helps your use-case?

@timvink timvink added the enhancement New feature or request label Mar 4, 2022
@Crystal-RainSlide
Copy link
Author

Crystal-RainSlide commented Mar 5, 2022

For me, I can just use JavaScript to change the strings afterwards, and I don't need to specify the sub-language tag right now, thus I'm not in a hurry.

The need is focused on pt_BR, zh_Hant / zh_HK / zh_TW and so on, as pt defaults to pt_PT, and zh defaults to zh_Hans / zh_CN.

SuibianP pushed a commit to SuibianP/utau-zh-docs that referenced this issue May 15, 2022
A new assertion of 2-letter locale codes was added into one dependency
and broke the page build.

This should not have happened, but needs to be worked around anyway.

This can be reverted once
timvink/mkdocs-git-revision-date-localized-plugin#86 is fixed.
@EDIflyer
Copy link

Agree would be good to change - I was trying using en-gb at first to get non-US date format but then realised only en was allowed 😉

@tooilxui
Copy link

tooilxui commented Oct 2, 2024

It is recommended to remove this restriction first. This will be very helpful for Chinese-speaking countries. For us, it is the same as zh but there are more than three differences.

@jonaharagon
Copy link

Will give it some thought next time I work on this plugin. In the meantime I could remove the assertion if that helps your use-case?

@timvink This would help my use-case, my zh-Hant mkdocs-material site builds are now broken after #143 was fixed.

@tooilxui
Copy link

Will give it some thought next time I work on this plugin. In the meantime I could remove the assertion if that helps your use-case?

@timvink This would help my use-case, my zh-Hant mkdocs-material site builds are now broken after #143 was fixed.

@jonaharagon agree with you

/cc @timvink

@LorhanSohaky
Copy link

Any update? I'm trying to use pt-br

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants