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

Translations with language+region fails #317

Closed
tdimeco opened this issue Oct 24, 2016 · 4 comments
Closed

Translations with language+region fails #317

tdimeco opened this issue Oct 24, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@tdimeco
Copy link

tdimeco commented Oct 24, 2016

Hi team,

Thank you for your quick fix #314 about missing french translation ;-)

I have another issue with this. The french strings bundle is named fr.lproj. SwiftDate targets the folder using the collatorIdentifier property of NSLocale. On my device, the result is fr-FR, so the french translation is not loaded but the english one (DateInRegionFormatter line 124).

Even stranger, on another french device (same language and region settings, both on iOS version 10.0.2), the result is fr and everything works as expected.

Do you have any solution for that?

Maybe by using NSLocale.languageCode which returns fr in all cases, but I don't know if it's ok for other languages like chinese ones.

Also, the issue may affects other languages in the bundle.

Thanks!

French Date Debug

@malcommac malcommac changed the title French translation is not working Translations with language+region fails Oct 26, 2016
@rbukovansky
Copy link
Contributor

Interesting... Following returns nil for all 4 on Linux. Any idea, why?

print("Locale.current.languageCode = \(String(describing: Locale.current.languageCode))")
print("Locale.current.collatorIdentifier = \(String(describing: Locale.current.collatorIdentifier))")
print("NSLocale.current.languageCode = \(String(describing: NSLocale.current.languageCode))")
print("NSLocale.current.collatorIdentifier = \(String(describing: NSLocale.current.collatorIdentifier))")

@rbukovansky
Copy link
Contributor

rbukovansky commented Nov 14, 2016

BTW I believe those folders with translations should be named after collatorIdentifier, like fr-FR.lproj.
There is i.e. portugal in Portugal (pt-PT) and portugal in Brasil (pt-BR) which can be different in some words. Chinese are having 2 languages as well, Chinese Traditional and Chinese Simplified (and maybe more).
Heck, there is even en-GB and en-US (i.e. colour vs. color etc.)...

@malcommac
Copy link
Owner

I think the best solution is, as you said, to use the collatorIdentifier.
i've fixed all folders in order to support this.
As default fallback we will return to en-US.

@rbukovansky
Copy link
Contributor

BTW Issue was reported to Swift bugtracking about those nil values: https://bugs.swift.org/browse/SR-3202

@malcommac malcommac added the bug label Nov 30, 2016
@malcommac malcommac added this to the 4.0.8 milestone Nov 30, 2016
@malcommac malcommac self-assigned this Nov 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants