Localisation d’applications
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
Internationalisation

• NSNumberFormatter

    - (NSString *)stringFromNumber:(NSNumber *)number




                  $1,000.00    1 000,00 $
Internationalisation

• NSDateFormatter

    - (NSString *)stringFromDate:(NSDate *)date


                    - (void)setDoesRelativeDateFormatting:(BOOL)b
                    + (NSString *)dateFormatFromTemplate:
                    (NSString *)template options:(NSUInteger)opts
                    locale:(NSLocale *)locale
   !!"#$%&'&
 NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
 NSString * dateComponents = @"yMMMMd";
 NSString * dateFormat = [NSDateFormatter dateFormatFromTemplate:dateComponents
 options:0 locale: [NSLocale currentLocale]];
 [dateFormatter setDateFormat:dateFormat];

                                         !

              September 9, 2010              9 Septembre 2010
Processus de localisation


 • Préparer la localisation

 • Traduire

 • Ajuster les élements d’interface
Localisation

• Fichiers .strings

    Encodage UTF-16

• Stockés sous forme key/value

    "clé" = "valeur";

• Accessibles avec :

    NSLocalizedString(@"Key", @"Localization hint");
    Fichier Localizable.strings
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é";
XIBs localisés
Démo
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!";
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";
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
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");
Recommendations

!
- (void)sq_layoutViewControls {
    ...

     // Percentages button
!   [displayPercentageButton sizeToFit];
!   NSRect displayPercentageButtonFrame = displayPercentageButton.frame;
!   displayPercentageButtonFrame.origin.x = borderMargin + 20;
!   displayPercentageButton.frame = displayPercentageButtonFrame;
}




              (UIView)
              - sizeToFit;
iOS
              (UITextField & UILabel)
              @property(nonatomic) BOOL adjustsFontSizeToFitWidth;



              (NSControl)
OS X
              - sizeToFit;
Recommendations

 Vos traducteurs
    • Laissez-les vous contacter
    • Uniquement des natifs
    • Vérifiez leur «CV»
    • Intégrez-les à vos béta testeurs

Slides de la Localisation

  • 1.
  • 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
  • 5.
    Internationalisation • NSNumberFormatter - (NSString *)stringFromNumber:(NSNumber *)number $1,000.00 1 000,00 $
  • 6.
    Internationalisation • NSDateFormatter - (NSString *)stringFromDate:(NSDate *)date - (void)setDoesRelativeDateFormatting:(BOOL)b + (NSString *)dateFormatFromTemplate: (NSString *)template options:(NSUInteger)opts locale:(NSLocale *)locale !!"#$%&'& NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; NSString * dateComponents = @"yMMMMd"; NSString * dateFormat = [NSDateFormatter dateFormatFromTemplate:dateComponents options:0 locale: [NSLocale currentLocale]]; [dateFormatter setDateFormat:dateFormat]; ! September 9, 2010 9 Septembre 2010
  • 7.
    Processus de localisation • Préparer la localisation • Traduire • Ajuster les élements d’interface
  • 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 pourscanner 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é";
  • 10.
  • 11.
  • 12.
    Recommendations • Utiliser desimages 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 desstrings 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 localiserles 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");
  • 16.
    Recommendations ! - (void)sq_layoutViewControls { ... // Percentages button ! [displayPercentageButton sizeToFit]; ! NSRect displayPercentageButtonFrame = displayPercentageButton.frame; ! displayPercentageButtonFrame.origin.x = borderMargin + 20; ! displayPercentageButton.frame = displayPercentageButtonFrame; } (UIView) - sizeToFit; iOS (UITextField & UILabel) @property(nonatomic) BOOL adjustsFontSizeToFitWidth; (NSControl) OS X - sizeToFit;
  • 17.
    Recommendations Vos traducteurs • Laissez-les vous contacter • Uniquement des natifs • Vérifiez leur «CV» • Intégrez-les à vos béta testeurs