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

Please add locale-specific toUpper/LowerCase #229

Open
robertoscaramuzzi opened this issue Feb 5, 2018 · 7 comments
Open

Please add locale-specific toUpper/LowerCase #229

robertoscaramuzzi opened this issue Feb 5, 2018 · 7 comments
Labels
package:intl type-enhancement A request for a change that isn't a bug

Comments

@robertoscaramuzzi
Copy link

Currently in our project we need to have separate Intl.messages for messages such as 'Paused' and 'PAUSED' because calling Intl.message('Paused').toUpperCase() might be wrong in some languages, namely Turkish, Azeri and Lithuanian.

This introduces the risk that the two messages might be translated differently, introducing confusion for the user.

Note that Intl has toBeginningOfSentenceCase that handles Turkish and Azeri (but not Lithuanian) so this doesn't seem like such a leap.

See http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/65464a307408/src/java.base/share/classes/java/lang/ConditionalSpecialCasing.java

for the OpenJDK implementation (or don't look at it if there are intellectual property issues).

@alan-knight
Copy link
Contributor

What are you asking for this to do? Is it just roughly the equivalent of
aString.split("").map((x) => toBeginningOfSentenceCase(x).join("");
perhaps with the addition of Lithuanian? I've been reluctant to do anything that would add a large amount of character data, and the urgent issue seemed to be around these couple of special cases. And you made me worried so I haven't looked at the OpenJDK version.

@robertoscaramuzzi
Copy link
Author

robertoscaramuzzi commented Feb 5, 2018 via email

@deadsoul44
Copy link

print(DateFormat('MMMM', 'tr')
        .format(DateTime(2020, 4, 1))
        .split("")
        .map((x) => toBeginningOfSentenceCase(x))
        .join(""));

The code above still prints NISAN instead of NİSAN.
Am I missing something?

@alan-knight
Copy link
Contributor

toBeginningOfSentenceCase has an optional locale parameter. If you have not set the default locale to 'tr', then you need to pass that parameter. Also, you don't need to do it for each character, you can just do it for the whole string, skipping the split/join.

@deadsoul44
Copy link

If I skip split/join, it does not work since i is the second letter.

@deadsoul44
Copy link

It is working fine after setting locale. Thank you.

@mosuem
Copy link
Member

mosuem commented Aug 9, 2023

Implementing this would be quite involved, see the reference implementation at https://icu.unicode.org/design/case/greek-upper. I would be happy to review PRs, if someone would like to attempt this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:intl type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants