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

"İ" doesn't change to "I" when the language is changed #78

Open
ulvidamirli opened this issue May 26, 2022 · 6 comments
Open

"İ" doesn't change to "I" when the language is changed #78

ulvidamirli opened this issue May 26, 2022 · 6 comments
Labels
bug Something isn't working examples Issue related to examples

Comments

@ulvidamirli
Copy link

ulvidamirli commented May 26, 2022

"i" and "ı" are two different letters in most Turkic languages.
Capital form of "i" is "İ" and "ı" is "I".

When I use uppercase form of string (by using CSS: text-transform: uppercase;), they don't change according to language standard. My browser is the latest version of Chrome. I don't define custom font, I use system default font.

For example:
<div style="text-transform: uppercase">This is my text</div>

  1. If the language is English when I first load the page:
    Output: THIS IS MY TEXT
    This is as expected.

  2. When I change language to Azerbaijani:
    Output: THIS IS MY TEXT
    But it should be: THİS İS MY TEXT

Testing vice-versa:

  1. If the language is Azerbaijani when I first load the page:
    Output: THİS İS MY TEXT
    This is as expected.

  2. When I change language to English:
    Output: THİS İS MY TEXT
    But it should be: THIS IS MY TEXT

This ambiguity occur only when I use text-transform: uppercase;. I don't get this problem if I type uppercased letters by hand. But I can't use this method in each page (project requirements). How can I solve this issue?

I don't really know if this is related to the sveltekit-i18n or not. I am sorry if I am in a wrong place for this issue :)

@jarda-svoboda
Copy link
Member

Wow… that seems like a bug, but not sure what exactly could cause this behavior..🤔
I’ll investigate this in near future and will keep you updated.)

@jarda-svoboda
Copy link
Member

Btw could you please provide some repro? Just to see your use case..

@jarda-svoboda
Copy link
Member

Ok, in your change locale process, you need to change your html lang attribute first to render your text-transform properly...

<html lang="az"> ... </html>

After your lang attribute is present, you can set the sveltekit-i18n locale using locale.set('az') or $locale = 'az' and it should render correctly...

@jarda-svoboda jarda-svoboda added bug Something isn't working examples Issue related to examples labels May 27, 2022
@ulvidamirli
Copy link
Author

Btw could you please provide some repro? Just to see your use case..

I am using the same code used in locale-router example.

Thank you very much for taking your time and providing your solution. And your library is really helping me a lot. But I don't understand how can I make html lang attribute reactive variable to bind with locale.

Is there a way to update html lang attribute without page reloading? I don't see any change when I change the locale.

@jarda-svoboda
Copy link
Member

As far as I know Svelte currently does not have any automated way how to change the lang attribute so you have to use something like:

document.querySelector('html').setAttribute('lang', YOUR_LOCALE)

currently, it’s not implemented in the examples so that’s why it currently does not work in the locale-router example..

@jarda-svoboda
Copy link
Member

Ok, for now, you could use this (bit hacky) solution:

<script>
  const handleLocaleChange = async ({ currentTarget = {} }) => {
    const {value} = currentTarget;

    document.querySelector('html').setAttribute('lang', value);
    
    // Don't ask me why this works and tick() not...
    await new Promise((res) => setTimeout(res, 0));
    
    locale.set(value);
  }
</script>

<select on:change={handleLocaleChange}>
  <option value="en">English</option>
  <option value="az">Azerbaijani</option>
</select>

I'll implement auto change mechanism for html lang attribute in future so you won't have to do it this way, but for now this works...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working examples Issue related to examples
Projects
None yet
Development

No branches or pull requests

2 participants