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

[suggestion] Use .stringsdict to properly represent plurals in all languages #277

Open
reggian opened this issue Jan 29, 2019 · 0 comments

Comments

@reggian
Copy link

reggian commented Jan 29, 2019

I think the usage of stringsdicts would bring DateTools to a new level by offering proper support for all languages without the need to hack the strings files with "__" rules.

Apple Documentation

Simple example of stringsdict for Slovenian:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>dt_seconds_ago</key>
	<dict>
		<key>NSStringLocalizedFormatKey</key>
		<string>%#@seconds@</string>
		<key>seconds</key>
		<dict>
			<key>NSStringFormatSpecTypeKey</key>
			<string>NSStringPluralRuleType</string>
			<key>NSStringFormatValueTypeKey</key>
			<string>d</string>
			<key>zero</key>
			<string>pravkar</string>
			<key>one</key>
			<string>sekundo nazaj</string>
			<key>two</key>
			<string>2 sekundi nazaj</string>
			<key>few</key>
			<string>%d sekunde nazaj</string>
			<key>other</key>
			<string>%d sekund nazaj</string>
		</dict>
	</dict>
</dict>
</plist>

The example usage (with forced SL locale):

let locale = Locale(identifier: "sl")
let format = NSLocalizedString("dt_seconds_ago", comment: "")
let string = String(format: format, locale: locale, 1)
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

No branches or pull requests

1 participant