2. Pourquoi localiser ?
• Meilleure expérience utilisateur
• Plus de clients
8 % 17 %
8 %
7 %
Irlande Belgique Grèce 18 %
Espagen Autriche Taiwan
Russie Turquie Chili
Equateur Malaisie Salvador
Australie Danemark Portugal
Pays Bas
Suisse
Italie
Japon
Allemagne
France
19 %
USA Royaume Uni
8. Localisation
• Fichiers .strings
Encodage UTF-16
• Stockés sous forme key/value
"clé" = "valeur";
• Accessibles avec :
NSLocalizedString(@"Key", @"Localization hint");
Fichier Localizable.strings
9. genstrings
• Outil pour scanner et produire un fichier .strings
• Insère les commentaires trouvés dans le code
• Accessible avec :
genstrings ./*.m
NSLocalizedString(@"Key", @"Localization hint");
/* Localization hint */
"Key" = "Clé";
12. Recommendations
• Utiliser des images le plus souvent possible
• Utiliser les variables “%1$@” pour permettre un ordre différent
/* Message in alert panel when something fails */
"Oh %@! %@ failed!" = "%2$@ blah blah, %1$@ oh!";
13. Recommendations
• Formattage des strings
NSLocalizedString(@"reversedDomainStyleKey", @"'English
translation' and localization hint");
/* 'English translation' and localization hint */
"reversedDomainStyleKey" = "reversedDomainStyleKey";
/* 'Enter passcode' text when unlocking the application */
"passCodeUnlockEnterPassCode" = "Saisissez le code";
/* 'Wrong passcode' text when unlocking the application */
"passCodeUnlockWrongPassCode" = "Code erroné";
/* 'Numeric keypad' in the settings */
"settingsNumericKeypad" = "Clavier numérique";
/* 'Enter Decimals Automatically' in the settings */
"settingsNumericKeypadEnterDecimalsAutomatically" = "Décimales automatiques";
/* 'Use Decimal Key' in the settings */
"settingsNumericKeypadUseDecimalKey" = "settingsNumericKeypadUseDecimalKey";
14. Recommendations
Eviter de localiser les XIBs
• Maintenance difficile
Localiser dans le code
• Traduire les labels, boutons, etc...
• Ajuster les élements d’interface
Avantages
• Résultat immédiat pour les traducteurs sous OS X
• Taille de l’application réduite
15. Recommendations
- (void)loadView {
! [super loadView];
!
! [self sq_localizeControls];
! [self sq_layoutViewControls];
}
- (void)sq_localizeControls {
! accountsHistoryLabel.stringValue = NSLocalizedStringFromTable(@"accountsHistoryLabelTitle",
@"PreferencesCharts", @"'Accounts history:' title of the corresponding label");
!
! graphTypeLabel.stringValue = NSLocalizedStringFromTable(@"graphTypeLabelTitle", @"PreferencesCharts",
@"'Graph type:' title of the corresponding label");
! [graphTypePopUpButton addItemWithTitle:NSLocalizedStringFromTable
(@"graphTypePopUpButtonBalanceHistoryItemTitle", @"PreferencesCharts", @"'Balance history' title of the menu
item to display the balance history in the history graph")]; @"PreferencesCharts", @"'Activate rotation'
title of the checkbox button to activate the Z-axis rotation of the history graph");
...
}
NSLocalizedStringFromTable(@"Key", @"Table",
@"Localization hint");