Move constant to fix translations - #591
Conversation
katinthehatsite
left a comment
There was a problem hiding this comment.
The solution works for me for the languages that use Latin characters. However, it breaks otherwise. For example, this is what happens in Russian:
First site gets created with Cyrillic characters:
Second site throws an error for the path:
This is the related issue: https://github.com/Automattic/dotcom-forge/issues/8648
I know this fixes the original issue but I am worried that it makes the user experience worse if we merge as is
|
@katinthehatsite it seems we need to rewrite our sanitization function. I did it in d07d306 |
| const CHINESE = '\\u4e00-\\u9fa5'; | ||
| const JAPANESE_HIRAGANA = '\\u3040-\\u309F'; | ||
| const JAPANESE_KATAKANA = '\\u30A0-\\u30FF'; | ||
| const KOREAN_HANGUL = '\\uAC00-\\uD7AF'; |
There was a problem hiding this comment.
The sanitization doesn't work for a Korean as NFKD normalization removes all Korean characters, producing an empty path.
Any smart way on how to solve that?
There was a problem hiding this comment.
Potential ways:
- Don't normalize string if a user uses Studio in Korean. It's an easy way, but edge cases won't work well e.g. user who uses Studio in Korean and uses Polish characters in the site name.
- replace Korean characters with placeholders before normalization and replace them back after. It would work in all cases, but seems overly complex.
There was a problem hiding this comment.
Yeah, I think we can skip normalization if Studio is in Korean.
There was a problem hiding this comment.
It seems I debugged it incorrectly and came to the wrong conclusion.
Korean syllables (Hangul) are decomposed by NKFD normalization into letters (Jamo). The initial regex included only syllables, so all letters were removed. I added Korean letters to the allowed list, which now works for all cases.
There was a problem hiding this comment.
Thanks for the fix, it looks good for me now 👍
I added Korean letters to the allowed list, which now works for all cases.
Nice work!
There was a problem hiding this comment.
I tested it in different languages and I confirm that all languages I tested except Korean produce a nice directory name.
As we discussed, I think the approach of not running normalization if the current Studio language is Korean is a good solution.
creating-sites-different-languages-except-korean.mp4
… syllables (Hagul) to letters
Related to #416 and https://github.com/Automattic/dotcom-forge/issues/8648
Proposed Changes
I propose to move constants to function to ensure phrases are translated after translations are loaded.
Testing Instructions
Pre-merge Checklist