Internationalization of the Asset Types


#1

I figured out how to do it, but I don’t think this is the best way.

First I created a custom Localizable.strings base file (without using the genstrings command)

[code]/* Name of application */
“Homepwner” = “Homepwner”;

/* Type label None */
“None” = “None”;

/* Asset type button */
“Type: %@” = “Type: %@”;

/* BNRAssetTypeViewController title */
“Asset Type” = “Asset Type”;

/* Electronics asset type */
“Electronics” = “Electronics”;

/* Furniture asset type */
“Furniture” = “Furniture”;

/* Jewelry asset type */
“Jewelry” = “Jewelry”;[/code]

Then I created the spanish version of the file:

[code]/* Name of application */
“Homepwner” = “Dueño de la casa”;

/* Type label None */
“None” = “Ninguno”;

/* Asset type button */
“Type: %@” = “Tipo: %@”;

/* BNRAssetTypeViewController title */
“Asset Type” = “Tipo de activo”;

/* Electronics asset type */
“Electronics” = “Electrónicos”;

/* Furniture asset type */
“Furniture” = “Mobiliario”;

/* Jewelry asset type */
“Jewelry” = “Joyería”;[/code]

After this I only replace some code in in BNRDetailViewController inside WillAppear: method:

NSString *typeLabel = nil; if (!item.assetType) { typeLabel = NSLocalizedString(@"None", @"Type label None"); } else { typeLabel = NSLocalizedString([self.item.assetType valueForKey:@"label"], nil); }

And in BNRAssetTypeViewController inside tableView: method:

I use nil in the second parameter because I created a custom file and I added the comments manually.

Is there a better way to do this?