fnando / i18n

A small library to provide the I18n translations on the JavaScript.
https://fnando.github.io/i18n/
MIT License
169 stars 20 forks source link

Bug: i18.t(key) key use like cardno or phoneno can not been properly found. #81

Closed ybupro closed 1 year ago

ybupro commented 1 year ago

Description

very similar key exist may return object but not string translation.

How to reproduce

For Example I have below two key with translation image

I get translation result below image

What do you expect

properly render result with similar key like cardno cardno. or phoneno phoneno.

What happened instead

return{"": undefined, "0": "P", "1": "h", "2": "o", "3": "n", "4": "e", "5": " ", "6": "#"}

Software:

using "i18n-js": "4.3.2"

fnando commented 1 year ago

could you please post a snippet reproducing the issue? I can't really grasp what's being reported.

ybupro commented 1 year ago

Hi Nando, I update the description. I am not sure exactly what will make I18n return object as the image I attach. The translation file I use is fetch from backend. In the file, there exists similar key like I attach, this scenario, it will return a object but not a string as other. DO you have any idea? Thank you!

fnando commented 1 year ago

oh, dots like in phoneno. won't work because . is the translation separator by default. This allows having things like i18n.t("messages.hello").

ybupro commented 1 year ago

could you please post a snippet reproducing the issue? I can't really grasp what's being reported.

oh, dots like in phoneno. won't work because . is the translation separator by default. This allows having things like i18n.t("messages.hello").

Got it, thank you for your prompt response.

andreyukD commented 6 months ago

I think it works now since this commit https://github.com/fnando/i18n/commit/f7de3c706cbc6029e5229706bda7cd0bca61273c (v4.4.0+)