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

feat: fallback cldr #820

Merged
merged 10 commits into from
Nov 5, 2020
Merged

feat: fallback cldr #820

merged 10 commits into from
Nov 5, 2020

Conversation

semoal
Copy link
Contributor

@semoal semoal commented Nov 3, 2020

Will close #791

  • Update docs
  • Add some extra testing
  • Clean some duplicated types

@vercel
Copy link

vercel bot commented Nov 3, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/lingui-js/js-lingui/1rzammu69
✅ Preview: https://js-lingui-git-fallback-cldr.lingui-js.vercel.app

@semoal
Copy link
Contributor Author

semoal commented Nov 3, 2020

Practically the feature is done,

  • if no fallbackLocales is passed we look the cldr parent locale of each locale in config file, and we create our own fallbackLocales through locales array
  • if fallbackLocales.default is passed we just use that :)
  • if fallbackLocale (deprecated), we create an object of fallbackLocales.default with that locale

I think all the cases are covered, I'm a bit tired now so probably something is not correct, I'll take a better look tomorrow

@semoal
Copy link
Contributor Author

semoal commented Nov 4, 2020

I'll do some extra testing on a sample project, to check 100% if all the cases are covered and we're ready to :shipit:

@codecov
Copy link

codecov bot commented Nov 4, 2020

Codecov Report

Merging #820 into main will decrease coverage by 0.83%.
The diff coverage is 66.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #820      +/-   ##
==========================================
- Coverage   84.71%   83.87%   -0.84%     
==========================================
  Files          39       39              
  Lines        1295     1333      +38     
  Branches      341      356      +15     
==========================================
+ Hits         1097     1118      +21     
- Misses        117      129      +12     
- Partials       81       86       +5     
Impacted Files Coverage Δ
packages/cli/src/api/catalog.ts 82.47% <11.11%> (-3.55%) ⬇️
packages/core/src/formats.ts 70.00% <74.07%> (-17.50%) ⬇️
packages/conf/src/index.ts 87.14% <84.61%> (+0.25%) ⬆️
packages/core/src/context.ts 89.58% <100.00%> (-0.22%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22667ad...e826353. Read the comment docs.

@semoal
Copy link
Contributor Author

semoal commented Nov 4, 2020

Tested on create-react-app of examples folder adding ES-MX and ES, translating some things in "es", appears in es-mx 👍🏻

So I think, it works as intended

@semoal semoal marked this pull request as ready for review November 4, 2020 18:13
Copy link
Contributor

@tricoder42 tricoder42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, great work! Just a few comments bellow, but this is going to be a huge improvement 👍

packages/conf/src/index.ts Outdated Show resolved Hide resolved
packages/conf/src/index.ts Outdated Show resolved Hide resolved
packages/cli/src/api/catalog.ts Outdated Show resolved Hide resolved
packages/cli/src/api/catalog.ts Outdated Show resolved Hide resolved
packages/core/src/formats.test.ts Show resolved Hide resolved
@tricoder42
Copy link
Contributor

Looking good! Thanks a lot 👍

@tricoder42 tricoder42 merged commit 2d9e124 into lingui:main Nov 5, 2020
@MartinCerny-awin
Copy link
Contributor

I am trying to use fallbackLocales and getting error

● Validation Warning:

  Unknown option "fallbackLocales" with value {"default": "en", "ps": ["en"]} was found. Did you mean "fallbackLocale"?
  This is probably a typing mistake. Fixing it will remove this message.

What is the correct way now to use it?

@MartinCerny-awin
Copy link
Contributor

Ok, I guess I am reading the latest docs for unreleased version

@tricoder42
Copy link
Contributor

@MartinCerny-awin Yes, sorry, there's currently a problem with latest release of docs... It'll be fixed early next week with new release setup

@semoal semoal deleted the fallback-cldr branch November 11, 2020 08:39
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 this pull request may close these issues.

Add fallback languages for the i18n instance.
3 participants