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

Use translation from default locale if provided locale is undefined or null #502

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

longdoan7421
Copy link

@longdoan7421 longdoan7421 commented Oct 2, 2022

Close #501.

  • Update singular translation API i18n.__
  • Update plural translation API i18n.__n

@coveralls
Copy link

coveralls commented Oct 3, 2022

Coverage Status

coverage: 98.175%. remained the same when pulling c1b5d7a on longdoan7421:master into 41b8801 on mashpie:master.

@mashpie
Copy link
Owner

mashpie commented Oct 3, 2022

thanks @longdoan7421 for submitting this PR. Did you plan to also complete any other methods?

@longdoan7421
Copy link
Author

Hi @mashpie, I'm gonna continue working on the plural method __n later today. My plan was that I will change the method getLocaleFromObject to return the defaultLocale instead of undefined as default value. Then, use that method to get locale config from the input in method __n. Do you think whether it would affect anything?

For the other methods, I don't see they have option to pass locale like i18n.__ and i18n.__n (not sure if I am right, maybe you can correct me for this part).

@longdoan7421
Copy link
Author

Hi @mashpie, sorry for the delay. I added the fix for API i18n.__n. Please take a look if there is something need to be improved.

@mashpie
Copy link
Owner

mashpie commented Dec 7, 2022

Thanks @longdoan7421 - and sry for delay. LGTM!

Hope to review closer and of week.

@EinfachHans
Copy link

Any updates on this?

@EinfachHans
Copy link

@longdoan7421 can you fix __mf as well?

@longdoan7421
Copy link
Author

@EinfachHans I was not aware of __mf function. Could you point me the documentation for that function? I will look at it and see what I can do.

@EinfachHans
Copy link

I use it because it integrates with messageformat: https://github.com/mashpie/i18n-node#i18n__mf At the end of the day this patch should be applied to all functions i guess 🤔

@longdoan7421
Copy link
Author

Hi @mashpie, I added a similar fix for method i18n.__mf. When you have time could you check this PR? Thank you.

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.

[Bug] translation API is returning undefined when provided locale is undefined or null
4 participants