i18n-node icon indicating copy to clipboard operation
i18n-node copied to clipboard

Use translation from default locale if provided locale is `undefined` or `null`

Open longdoan7421 opened this issue 2 years ago • 10 comments

Close #501.

  • [x] Update singular translation API i18n.__
  • [x] Update plural translation API i18n.__n

longdoan7421 avatar Oct 02 '22 18:10 longdoan7421

Coverage Status

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

coveralls avatar Oct 03 '22 13:10 coveralls

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

mashpie avatar Oct 03 '22 13:10 mashpie

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 avatar Oct 03 '22 14:10 longdoan7421

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.

longdoan7421 avatar Oct 05 '22 12:10 longdoan7421

Thanks @longdoan7421 - and sry for delay. LGTM!

Hope to review closer and of week.

mashpie avatar Dec 07 '22 07:12 mashpie

Any updates on this?

EinfachHans avatar Mar 14 '23 09:03 EinfachHans

@longdoan7421 can you fix __mf as well?

EinfachHans avatar Mar 14 '23 09:03 EinfachHans

@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.

longdoan7421 avatar Mar 18 '23 12:03 longdoan7421

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 🤔

EinfachHans avatar Mar 19 '23 15:03 EinfachHans

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

longdoan7421 avatar Jun 25 '23 16:06 longdoan7421