Smartling / ios-i18n

The ios-i18n library provides seamless integration of plurals into iOS 6 apps.
http://www.smartling.com
Apache License 2.0
205 stars 41 forks source link

Correctly handle string table names with fallback langs #11

Closed JensAyton closed 10 years ago

JensAyton commented 10 years ago

Prior to this change, if you passed a custom table name and used a language where a fallback language was used to determine the pluralization rule, the tableName variable would be passed to [self pathForResource:...] multiple times. On the second time, passing an absolute string would produce a nil result.

This would happen, for example, for Mexican Spanish, where the lang list is ("es_MX", "es-MX", "es", "English"), and "es" determines the pluralization rule.

JensAyton commented 10 years ago

On further consideration, this is wrong; it will result in es-ES strings being used when pluralization is used. The correct approach is to look up the files up front so that you only get the es_MX strings. (NSBundle will fall back to es and English if no es_MX exists.)