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

[RFC] Providing own locales for built-in texts #1065

Open
amje opened this issue Oct 23, 2023 · 4 comments · May be fixed by #1844
Open

[RFC] Providing own locales for built-in texts #1065

amje opened this issue Oct 23, 2023 · 4 comments · May be fixed by #1844
Assignees

Comments

@amje
Copy link
Contributor

amje commented Oct 23, 2023

Currently there are only two locales available, en and ru. There should be a way to pass any custom locale.

@NikitaShkaruba
Copy link

I'll think what I can do. I'll come back in a couple of days with a plan

@NikitaShkaruba
Copy link

NikitaShkaruba commented Sep 11, 2024

I've submitted some code here #1844
@amje, @korvin89, @ValeraS, can you look at this PR, please?

@NikitaShkaruba NikitaShkaruba changed the title [RFC] Providing own locales for built-it texts [RFC] Providing own locales for built-in texts Sep 11, 2024
@NikitaShkaruba
Copy link

NikitaShkaruba commented Sep 11, 2024

BTW why don't we just accept pull requests with new language keysets? This looks simpler, compared to calling a separate function before the app startup.

But yeah, it prolongs the onboarding process for a foreign project, because you need to either make a fork and fix it there, or to wait for the PR to be accepted

@NikitaShkaruba
Copy link

NikitaShkaruba commented Sep 15, 2024

We've talked about it, and the implementation in #1844 lacks proper typing.

The new idea is to infer keys from */i18n/en.json files, something like this:

import type BreadcrumbsEn from '../../../Breadcrumbs/en.json';
import type DialogEn from '../../../Dialog/i18n/en.json';

type Keysets = {
    breadcrumbs: typeof BreadcrumbsEn;
    dialog: typeof DialogEn;
};

function test() {
    const keyset: Keysets = {
        dialog: {
            close: 'Chiudere',
        },
        breadcrumbs: {
            breadcrumbs: 'briciole di pane',
            label_more: 'Di più',
        },
    };
    registerCustomKeyset('it', keyset);
}

But in this implementation we'll need to add newly added component keys manually to this Keysets type, and if the developer of new component forgets about Keysets, our users might see this component untranslated. So I'm thinking about running a little script before every commit with Husky, that will ensure keysets' integrity for us. What do you think, guys? @korvin89 @ValeraS

Also I've heard that you have some parts of code ready, what will we do with it?

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

Successfully merging a pull request may close this issue.

2 participants