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

Proposal: include translations #1567

Closed
jackocnr opened this issue Apr 12, 2024 · 3 comments
Closed

Proposal: include translations #1567

jackocnr opened this issue Apr 12, 2024 · 3 comments

Comments

@jackocnr
Copy link
Owner

jackocnr commented Apr 12, 2024

It would be helpful to include the translations for all of the country names (as well as the other 7 strings handled by the i18n option - see readme) in a few of the most popular languages, to save developers having to source the translations for themselves every time.

These could be stored as individual ES Module files e.g. for German:

// i18n/de.mjs
export default {
    fr: "Frankreich",
    de: "Deutschland",
    es: "Spanien",
    it: "Italien",
    ch: "Schweiz",
    nl: "Niederlande",
    at: "Österreich",
    dk: "Dänemark",
    // ...
    selectedCountryAriaLabel: "Ausgewähltes Land",
    noCountrySelected: "Kein Land ausgewählt",
    countryListAriaLabel: "Liste der Länder",
    searchPlaceholder: "Suchen",
    zeroSearchResults: "Keine Suchergebnisse",
    oneSearchResult: "1 Suchergebnis",
    multipleSearchResults: "${count} Suchergebnisse",
  };

These files can then be imported and then passed in via the i18n initialisation option e.g. something like this:

import intlTelInput from "intl-tel-input";
import de from "intl-tel-input/i18n/de";

intlTelInput(input, { i18n: de });

We wouldn't need to be comprehensive to begin with - one option would be to literally start with just a single language, and then build from there. I'm guessing at least the country name translations should be easy to come by - there must be repos out there containing this info already.

cc: @anthony0030 in case you have any time/interest in this, perhaps starting with Greek? 😉

@anthony0030
Copy link
Contributor

Hello again my friend (@jackocnr) 😃

I am happy to help with this feature. I have it working but I will need some help with the documentation and the imports/exports to make them cleaner.

if you add a translation file to src/i18n it will make the rest of the needed files.

I will make a pull request but it needs more review, docs, and improvements.

@anthony0030
Copy link
Contributor

Some notes/questions.

The reason the interface and countries are split: It allows you to just localize the interface while still leaving the country names in English.

Should we hard code the translation files in the src or import them like I am doing now?

Do you think it is worth making a translation file that has each country in the most common language of that country?
This might cause conflicts in places that have multiple languages.

looking forward to hearing back from you.

@jackocnr
Copy link
Owner Author

Released in v21.2.0

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

No branches or pull requests

2 participants