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

Barrelling and Factory for Languages #207

Closed
4 tasks done
BeauBouchard opened this issue Oct 31, 2022 · 0 comments
Closed
4 tasks done

Barrelling and Factory for Languages #207

BeauBouchard opened this issue Oct 31, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@BeauBouchard
Copy link
Member

BeauBouchard commented Oct 31, 2022

First outlined by @nickcrisci in a very well-thought-out and great contribution PR #206

I wanted to define a little bit how this change works and outline some of its improvements in an issue.

What this does

  • makes it so all you need is to create the new src/models/localization/ with some additional fields, and no longer need to edit /middleware or other files to configure accepting the new languages.
  • the accepted languages update based on the files in the folder, allowing quicker contributions and ease of development.

How this is done

[TO-DO] @BeauBouchard CC @switchhalt [fill this part out in more detail]

We want to adhere to the Standards for Content-Language and Accept-Language going forward.

Note: Language tags are formally defined in RFC 5646, which rely on the ISO 639 standard (quite often the ISO 639-1 code list) for language codes to be used.

Adds a short configurable field at the top of the facts file which specifies our agreed on conventions for querying it in the I18N codes we use.

In this example, we add a new language file for Canadian English.

It would be src/models/localization/eng-ca.js and look like

const facts = [
  "Cats have been the most popular pet for families in Canada since data was first collected in 1987.",
  "..."
];

const langName = "English", // normally this is the language name
  langISO = "eng", 
  langLocale = "ca", 
  langLocaleName = "Canadian"; 

module.exports = {
  langName,
  langISO,
  langLocale,
  langLocaleName,
  code: `${langISO}-${langLocale}`,
  codeName: `${langName} (${langLocaleName})`,
  facts: facts,
};

If you query the api with eng-ca language parameter you will get the facts appearing more for the tailored localization in the language of english.

Feel free to change the facts to be more meaningful to the location you want, as the original english facts are with america in mind, I would love to see what other places have for accurate and high quality facts about cats.

Work

  • merge this PR after it is passed which completes the majority of the work for this endeavor Enhancement/languages (#206) #208
  • add additional documentation to the existing localization issue here [I18N] Looking for Help With Translation #175
  • add additional documentation to the README.md listing the languages
  • create a new issue to demonstrate how a new language could be added, as well as making a few other issues more concise and specific for their contributions with less additional work in middleware/routing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants