SlideShare une entreprise Scribd logo
1  sur  104
Internationalisation du
        Front


                           Yannick Croissant
        Paris Web 2010 – 14-16 octobre 2010
Présentation
         Yannick Croissant
• Développeur Front dans l’Agence
    Interactive de TF1
• S’occupe de toute la partie front de
    différents sites d’équipes sportives.




•
Internationalisation
Internationalisation
  du côté de l’intégrateur
Différents éléments
      concernés :
• Templates HTML
• Images
• CSS
• Javascript
Templates HTML
Utilisez les capacités de
        vos outils
CMS       Wordpress       __('Hello World')



Framework    Django     {% trans 'Hello World' %}



Language      PHP           _('Hello World')
Tous utilisent la même
chose pour fonctionner
Gettext
Gettext

index.html    article.html   archives.html




             monsite.pot
CMS       Wordpress       __('Hello World')



Framework    Django     {% trans 'Hello World' %}



Language      PHP           _('Hello World')
Générer le fichier .pot
•   Wordpress: i18n Tools
         http://codex.wordpress.org/I18n_for_WordPress_Developers


•   Django: django-admin.py makemessages
          http://docs.djangoproject.com/en/1.2/topics/i18n/localization


•   PHP: xgettext
         http://gettext.sourceforge.net/



Etc...
Mes petits outils à moi

           AutoGetText




   http://github.com/Country/Utils
Mes petits outils à moi

           AutoGetText




   http://github.com/Country/Utils
Gettext

           monsite.pot




fr-FR.mo                 en-US.mo
Template source
<!DOCTYPE html>
<html lang="{% trans 'lang' %}">
 <head>
  <meta charset="utf-8" />
  <title>{% trans 'site-title' %}</title>
[...]
Site français
<!DOCTYPE html>
<html lang="fr-FR">
 <head>
  <meta charset="utf-8" />
  <title>Mon site</title>
[...]
Site anglais
<!DOCTYPE html>
<html lang="en-US">
 <head>
  <meta charset="utf-8" />
  <title>My Website</title>
[...]
Images
Vos images contiennent
  elles aussi du texte
Parlons découpe
Découpe
Découpe
•   Sprites
Découpe
•   Sprites
    • Horizontaux
Découpe
•   Sprites
    • Horizontaux
    • Verticaux
Découpe
•   Sprites
    • Horizontaux
    • Verticaux
    • Uniques
Découpe
•   Sprites
    • Horizontaux
    • Verticaux
    • Uniques
•   Formats
Découpe
•   Sprites
    • Horizontaux
    • Verticaux
    • Uniques
•   Formats
    • GIF
Découpe
•   Sprites
    • Horizontaux
    • Verticaux
    • Uniques
•   Formats
    • GIF
    • PNG8
Découpe
•   Sprites
    • Horizontaux
    • Verticaux
    • Uniques
•   Formats
    • GIF
    • PNG8
    • PNG32
Découpe
•   Sprites
    • Horizontaux
    • Verticaux
    • Uniques
•   Formats
    • GIF
    • PNG8
    • PNG32
    • JPEG
Découpe
•   Sprites
    • Horizontaux
    • Verticaux
    •   Uniques
•   Formats
    • GIF
    •   PNG8
    •   PNG32
    •   JPEG
Centralisez vos textes




   http://s.lnb.fr/lnb/file/assets/image/generic/titles.png
Centralisez vos textes
      (et surtout pas comme ça)




    http://www.olweb.fr/image/generic/menu.png
Centralisez vos textes
      (et surtout pas comme ça)




    http://www.olweb.fr/image/generic/menu.png
Conservez vos PSD
Conservez vos PSD
Conservez vos PSD
Conservez vos PSD
On peut commencer à traduire
On peut commencer à traduire

fr-FR
On peut commencer à traduire

fr-FR



en-US
On peut commencer à traduire

fr-FR



en-US


        Vos sprites doivent
          être identiques
              (enfin, si possible)
CSS
Eléments à traduire


• Peu de changements.
• On a déjà fait le plus gros du travail:
  templates et images.
.button {
    background:url(button-fr-FR.png) no-repeat -25px -30px;
    height:20px;
    margin:0 0 0 10px;
    width:125px;
}
<!DOCTYPE html>
<html lang="en-US">
 <head>
  <meta charset="utf-8" />
  <title>My Website</title>
[...]
<!DOCTYPE html>
<html lang="en-US">
 <head>
  <meta charset="utf-8" />
  <title>My Website</title>
[...]
.button {
    background:url(button-fr-FR.png) no-repeat -25px -30px;
    height:20px;
    margin:0 0 0 10px;
    width:125px;
}

[lang='en-US'] .button {
    background-image:url(button-en-US.png);
}
fr-FR



en-US
<!DOCTYPE html>
<html lang="ar-AR" dir="rtl">
 <head>
  <meta charset="utf-8" />
  <title>‫/<ﺍﺧﺘﺒﺎﺭ‬title>
[...]
.button {
    background:url(button-fr-FR.png) no-repeat -25px -30px;
    height:20px;
    margin:0 0 0 10px;
    width:125px;
}

[lang='en-US'] .button {
    background-image:url(button-en-US.png);
}

[lang='ar-AR'] .button {
    background-image:url(button-ar-AR.png);
    width:100px;
}

[dir='ltr'] .button {
    margin:0 10px 0 0;
}
Fonctionne partout
Fonctionne partout
      (Sauf sous IE6)
Si vous devez encore
    supporter IE6
Si vous devez encore
       supporter IE6
Utilisez des class sur votre <body>
<body class="lang-ar-AR dir-rtl">
Si vous devez encore
       supporter IE6
Utilisez des class sur votre <body>
<body class="lang-{% trans 'lang' %} dir-{% trans
'dir' %}">
Si vous devez encore
       supporter IE6
Utilisez des class sur votre <body>
<body class="lang-{% trans 'lang' %} dir-{% trans
'dir' %}">



Votre CSS deviendra alors:
.lang-ar-AR .button { ... }

.dir-rtl .button { ... }
Un ou plusieurs fichiers
        CSS ?
Un ou plusieurs fichiers
        CSS ?
• Dépend du projet.
Un ou plusieurs fichiers
        CSS ?
• Dépend du projet.
• 2 ou 3 langues: 1 seul fichier suffit
  généralement.
Un ou plusieurs fichiers
        CSS ?
• Dépend du projet.
• 2 ou 3 langues: 1 seul fichier suffit
  généralement.
• + de langues et/ou beaucoup de
  changements: penser à diviser en plusieurs
  fichiers.
Un ou plusieurs fichiers
        CSS ?
• Dépend du projet.
• 2 ou 3 langues: 1 seul fichier suffit
  généralement.
• + de langues et/ou beaucoup de
  changements: penser à diviser en plusieurs
  fichiers.
<link rel="stylesheet" href="css/global.css" />
<link rel="stylesheet" href="css/en-US.css" />
Dans le cas d’une division en plusieurs fichiers:
        Plus besoin d’utiliser le sélecteur sur l’attribut lang


global.css :
.button {
    background:url(button-fr-FR.png) no-repeat -25px -30px;
    height:20px;
    margin:0 0 0 10px;
    width:125px;
}


en-US.css :
.button {
    background-image:url(button-en-US.png);
}
Javascript
De plus en plus de
contenu généré par
     Javascript
Mootools
MooTools.lang.set('fr-FR', 'Example', {
  helloWorld: 'Bonjour Monde'
});
MooTools.lang.set('en-US', 'Example', {
  helloWorld: 'Hello World'
});

MooTools.lang.setLanguage(document.documentElement.lang);
alert(MooTools.lang.get('Example', 'helloWorld'));




                     http://www.mootools.net/docs/more/Core/Lang
MooTools.lang.set('fr-FR', 'Example', {
  helloWorld: 'Bonjour Monde'
});
MooTools.lang.set('en-US', 'Example', {
  helloWorld: 'Hello World'
});

MooTools.lang.setLanguage(document.documentElement.lang);
alert(MooTools.lang.get('Example', 'helloWorld'));




                     http://www.mootools.net/docs/more/Core/Lang
MooTools.lang.set('fr-FR', 'Example', {
  helloWorld: 'Bonjour Monde'
});
MooTools.lang.set('en-US', 'Example', {
  helloWorld: 'Hello World'
});

MooTools.lang.setLanguage(document.documentElement.lang);
alert(MooTools.lang.get('Example', 'helloWorld'));




                     http://www.mootools.net/docs/more/Core/Lang
MooTools.lang.set('fr-FR', 'Example', {
  helloWorld: 'Bonjour Monde'
});
MooTools.lang.set('en-US', 'Example', {
  helloWorld: 'Hello World'
});

MooTools.lang.setLanguage(document.documentElement.lang);
alert(MooTools.lang.get('Example', 'helloWorld'));




                     http://www.mootools.net/docs/more/Core/Lang
MooTools.lang.set('fr-FR', 'Example', {
  helloWorld: 'Bonjour Monde'
});
MooTools.lang.set('en-US', 'Example', {
  helloWorld: 'Hello World'
});

MooTools.lang.setLanguage(document.documentElement.lang);
alert(MooTools.lang.get('Example', 'helloWorld'));




                     http://www.mootools.net/docs/more/Core/Lang
MooTools.lang.set('fr-FR', 'Example', {
  helloWorld: 'Bonjour Monde'
});
MooTools.lang.set('en-US', 'Example', {
  helloWorld: 'Hello World'
});

MooTools.lang.setLanguage(document.documentElement.lang);
alert(MooTools.lang.get('Example', 'helloWorld'));




                     http://www.mootools.net/docs/more/Core/Lang
MooTools.lang.set('fr-FR', 'Example', {
  helloWorld: 'Bonjour Monde'
});
MooTools.lang.set('en-US', 'Example', {
  helloWorld: 'Hello World'
});

MooTools.lang.setLanguage(document.documentElement.lang);
alert(MooTools.lang.get('Example', 'helloWorld'));




                     http://www.mootools.net/docs/more/Core/Lang
jQuery
• Pas de support natif
• Pas de support natif
• Plugin
• Pas de support natif
• Plugin: jQuery i18n de Bryan Berry
      http://github.com/bryanwb/jquery-18n
$.i18n['en-US']    = {
   strings: {
     helloWorld:   'Hello World'
   }
};
$.i18n['fr-FR']    = {
   strings: {
     helloWorld:   'Bonjour Monde'
   }
};

$.i18n.setLocale(document.documentElement.lang);
alert($.i18n('helloWorld'));
$.i18n['en-US']    = {
   strings: {
     helloWorld:   'Hello World'
   }
};
$.i18n['fr-FR']    = {
   strings: {
     helloWorld:   'Bonjour Monde'
   }
};

$.i18n.setLocale(document.documentElement.lang);
alert($.i18n('helloWorld'));
$.i18n['en-US']    = {
   strings: {
     helloWorld:   'Hello World'
   }
};
$.i18n['fr-FR']    = {
   strings: {
     helloWorld:   'Bonjour Monde'
   }
};

$.i18n.setLocale(document.documentElement.lang);
alert($.i18n('helloWorld'));
$.i18n['en-US']    = {
   strings: {
     helloWorld:   'Hello World'
   }
};
$.i18n['fr-FR']    = {
   strings: {
     helloWorld:   'Bonjour Monde'
   }
};

$.i18n.setLocale(document.documentElement.lang);
alert($.i18n('helloWorld'));
$.i18n['en-US']    = {
   strings: {
     helloWorld:   'Hello World'
   }
};
$.i18n['fr-FR']    = {
   strings: {
     helloWorld:   'Bonjour Monde'
   }
};

$.i18n.setLocale(document.documentElement.lang);
alert($.i18n('helloWorld'));
$.i18n['en-US']    = {
   strings: {
     helloWorld:   'Hello World'
   }
};
$.i18n['fr-FR']    = {
   strings: {
     helloWorld:   'Bonjour Monde'
   }
};

$.i18n.setLocale(document.documentElement.lang);
alert($.i18n('helloWorld'));
$.i18n['en-US']    = {
   strings: {
     helloWorld:   'Hello World'
   }
};
$.i18n['fr-FR']    = {
   strings: {
     helloWorld:   'Bonjour Monde'
   }
};

$.i18n.setLocale(document.documentElement.lang);
alert($.i18n('helloWorld'));
La votre
var i18n = {
    'en-US': {
        helloWorld: 'Hello World'
    },
    'fr-FR': {
        helloWorld: 'Bonjour Monde'
    }
};

var currentLanguage = document.documentElement.lang;
alert(i18n[currentLanguage].helloWorld);
var i18n = {
    'en-US': {
        helloWorld: 'Hello World'
    },
    'fr-FR': {
        helloWorld: 'Bonjour Monde'
    }
};

var currentLanguage = document.documentElement.lang;
alert(i18n[currentLanguage].helloWorld);
var i18n = {
    'en-US': {
        helloWorld: 'Hello World'
    },
    'fr-FR': {
        helloWorld: 'Bonjour Monde'
    }
};

var currentLanguage = document.documentElement.lang;
alert(i18n[currentLanguage].helloWorld);
var i18n = {
    'en-US': {
        helloWorld: 'Hello World'
    },
    'fr-FR': {
        helloWorld: 'Bonjour Monde'
    }
};

var currentLanguage = document.documentElement.lang;
alert(i18n[currentLanguage].helloWorld);
var i18n = {
    'en-US': {
        helloWorld: 'Hello World'
    },
    'fr-FR': {
        helloWorld: 'Bonjour Monde'
    }
};

var currentLanguage = document.documentElement.lang;
alert(i18n[currentLanguage].helloWorld);
var i18n = {
    'en-US': {
        helloWorld: 'Hello World'
    },
    'fr-FR': {
        helloWorld: 'Bonjour Monde'
    }
};

var currentLanguage = document.documentElement.lang;
alert(i18n[currentLanguage].helloWorld);
var i18n = {
    'en-US': {
        helloWorld: 'Hello World'
    },
    'fr-FR': {
        helloWorld: 'Bonjour Monde'
    }
};

var currentLanguage = document.documentElement.lang;
alert(i18n[currentLanguage].helloWorld);
var i18n = {
    'en-US': {
        helloWorld: 'Hello World'
    },
    'fr-FR': {
        helloWorld: 'Bonjour Monde'
    }
};

var currentLanguage = document.documentElement.lang;
alert(i18n[currentLanguage].helloWorld);
Mes petits outils à moi
          (2)
          AutoGetText JS




   http://github.com/Country/Utils
Mes petits outils à moi
          (2)
          AutoGetText JS




   http://github.com/Country/Utils
Organisation
Solution 1

<script src="js/framework.js"></script>
<script src="js/lang-{% trans 'lang' %}.js"></script>
<script src="js/scripts.js"></script>
Solution 2


<script src="js/global-{% trans 'lang' %}.js"></script>
Solution 2


<script src="js/global-{% trans 'lang' %}.js"></script>




global-fr-FR.js = framework.js + lang-fr-FR.js + scripts.js
global-en-US.js = framework.js + lang-en-US.js + scripts.js
etc...
Résultat
<!DOCTYPE html>
<html lang="fr-FR">
 <head>
[...]
Résultat
<!DOCTYPE html>
<html lang="en-US">
 <head>
[...]
Merci !
    http://github.com/Country
                      *
    http://yannick.cr
    http://twitter.com/yannickc



                                Des questions ?

* Un peu mort, mais j’y travaille

Contenu connexe

Tendances

HTML5 - Sémantique, structure et nouveaux éléments
HTML5 - Sémantique, structure et nouveaux élémentsHTML5 - Sémantique, structure et nouveaux éléments
HTML5 - Sémantique, structure et nouveaux élémentsRémy Savard
 
Vive les tableaux de mise en page !
Vive les tableaux de mise en page !Vive les tableaux de mise en page !
Vive les tableaux de mise en page !Raphaël Goetter
 
Panels, une autre façon de construire. DrupalCamp Paris 2013
Panels, une autre façon de construire. DrupalCamp Paris 2013Panels, une autre façon de construire. DrupalCamp Paris 2013
Panels, une autre façon de construire. DrupalCamp Paris 2013bellesmanieres
 
Développement d’extensions WordPress
Développement d’extensions WordPressDéveloppement d’extensions WordPress
Développement d’extensions WordPressChi Nacim
 
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et JavascriptCodedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascriptcodedarmor
 
Web perf et rdc par Stephane Rios
Web perf et rdc par Stephane RiosWeb perf et rdc par Stephane Rios
Web perf et rdc par Stephane RiosAtlantic 2.0
 
Creation de-themes-wp
Creation de-themes-wpCreation de-themes-wp
Creation de-themes-wpChi Nacim
 
Un site mobile en une heure ? Top chrono ! (Barcamp-Bordeaux 2011)
Un site mobile en une heure ? Top chrono ! (Barcamp-Bordeaux 2011)Un site mobile en une heure ? Top chrono ! (Barcamp-Bordeaux 2011)
Un site mobile en une heure ? Top chrono ! (Barcamp-Bordeaux 2011)Raphaël Goetter
 
WordPress en tant que CMS
WordPress en tant que CMSWordPress en tant que CMS
WordPress en tant que CMSChi Nacim
 
Développement Web - HTML5, CSS3, APIs Web
Développement Web - HTML5, CSS3, APIs WebDéveloppement Web - HTML5, CSS3, APIs Web
Développement Web - HTML5, CSS3, APIs WebYoann Gotthilf
 

Tendances (11)

HTML5 - Sémantique, structure et nouveaux éléments
HTML5 - Sémantique, structure et nouveaux élémentsHTML5 - Sémantique, structure et nouveaux éléments
HTML5 - Sémantique, structure et nouveaux éléments
 
Vive les tableaux de mise en page !
Vive les tableaux de mise en page !Vive les tableaux de mise en page !
Vive les tableaux de mise en page !
 
Panels, une autre façon de construire. DrupalCamp Paris 2013
Panels, une autre façon de construire. DrupalCamp Paris 2013Panels, une autre façon de construire. DrupalCamp Paris 2013
Panels, une autre façon de construire. DrupalCamp Paris 2013
 
Développement d’extensions WordPress
Développement d’extensions WordPressDéveloppement d’extensions WordPress
Développement d’extensions WordPress
 
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et JavascriptCodedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
Codedarmor 2012 - 06/03 - HTML5, CSS3 et Javascript
 
Web perf et rdc par Stephane Rios
Web perf et rdc par Stephane RiosWeb perf et rdc par Stephane Rios
Web perf et rdc par Stephane Rios
 
Creation de-themes-wp
Creation de-themes-wpCreation de-themes-wp
Creation de-themes-wp
 
Un site mobile en une heure ? Top chrono ! (Barcamp-Bordeaux 2011)
Un site mobile en une heure ? Top chrono ! (Barcamp-Bordeaux 2011)Un site mobile en une heure ? Top chrono ! (Barcamp-Bordeaux 2011)
Un site mobile en une heure ? Top chrono ! (Barcamp-Bordeaux 2011)
 
WordPress en tant que CMS
WordPress en tant que CMSWordPress en tant que CMS
WordPress en tant que CMS
 
Développement Web - HTML5, CSS3, APIs Web
Développement Web - HTML5, CSS3, APIs WebDéveloppement Web - HTML5, CSS3, APIs Web
Développement Web - HTML5, CSS3, APIs Web
 
HTML5
HTML5HTML5
HTML5
 

Similaire à Internationalisation du Front

ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...Horacio Gonzalez
 
Un site web responsive en une heure
Un site web responsive en une heureUn site web responsive en une heure
Un site web responsive en une heureRaphaël Goetter
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...Horacio Gonzalez
 
ISCOM::HTML/CSS::session1 (20140930)
ISCOM::HTML/CSS::session1 (20140930)ISCOM::HTML/CSS::session1 (20140930)
ISCOM::HTML/CSS::session1 (20140930)Nicolas Aguenot
 
Javascript as a first programming language : votre IC prête pour la révolution !
Javascript as a first programming language : votre IC prête pour la révolution !Javascript as a first programming language : votre IC prête pour la révolution !
Javascript as a first programming language : votre IC prête pour la révolution !VISEO
 
WEBINAR SEO INTERNATIONAL 5 mai 2022.pptx
WEBINAR SEO INTERNATIONAL 5 mai 2022.pptxWEBINAR SEO INTERNATIONAL 5 mai 2022.pptx
WEBINAR SEO INTERNATIONAL 5 mai 2022.pptxPhilippe YONNET
 
Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Aurélien Maury
 
HTML5 maintenant partie 1 : la sémantique
HTML5 maintenant partie 1 : la sémantiqueHTML5 maintenant partie 1 : la sémantique
HTML5 maintenant partie 1 : la sémantiqueJean-Pierre Vincent
 
Confoo - 2012-02-27 au 2012-02-28 - HTML5 workshop
Confoo - 2012-02-27 au 2012-02-28 - HTML5 workshopConfoo - 2012-02-27 au 2012-02-28 - HTML5 workshop
Confoo - 2012-02-27 au 2012-02-28 - HTML5 workshopFrédéric Harper
 
technologie web - part2
technologie web - part2technologie web - part2
technologie web - part2Benoît Simard
 
Conception Web Avec Dreamweaver
Conception Web Avec DreamweaverConception Web Avec Dreamweaver
Conception Web Avec Dreamweaverdavidbx
 
Beautiful CSS : Structurer, documenter, maintenir
Beautiful CSS : Structurer, documenter, maintenirBeautiful CSS : Structurer, documenter, maintenir
Beautiful CSS : Structurer, documenter, maintenirYves Van Goethem
 
Développement Web sur iPhone (iPhone+iPad DevCamp Québec)
Développement Web sur iPhone (iPhone+iPad DevCamp Québec)Développement Web sur iPhone (iPhone+iPad DevCamp Québec)
Développement Web sur iPhone (iPhone+iPad DevCamp Québec)Rémi Prévost
 

Similaire à Internationalisation du Front (20)

ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
 
Un site web responsive en une heure
Un site web responsive en une heureUn site web responsive en une heure
Un site web responsive en une heure
 
Html5 now light
Html5 now lightHtml5 now light
Html5 now light
 
HTML5, le nouveau buzzword
HTML5, le nouveau buzzwordHTML5, le nouveau buzzword
HTML5, le nouveau buzzword
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
 
Paris Web
Paris WebParis Web
Paris Web
 
HTML
HTMLHTML
HTML
 
Atelier template
Atelier templateAtelier template
Atelier template
 
ISCOM::HTML/CSS::session1 (20140930)
ISCOM::HTML/CSS::session1 (20140930)ISCOM::HTML/CSS::session1 (20140930)
ISCOM::HTML/CSS::session1 (20140930)
 
Drupal & Mobilité
Drupal & MobilitéDrupal & Mobilité
Drupal & Mobilité
 
Javascript as a first programming language : votre IC prête pour la révolution !
Javascript as a first programming language : votre IC prête pour la révolution !Javascript as a first programming language : votre IC prête pour la révolution !
Javascript as a first programming language : votre IC prête pour la révolution !
 
WEBINAR SEO INTERNATIONAL 5 mai 2022.pptx
WEBINAR SEO INTERNATIONAL 5 mai 2022.pptxWEBINAR SEO INTERNATIONAL 5 mai 2022.pptx
WEBINAR SEO INTERNATIONAL 5 mai 2022.pptx
 
Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011
 
HTML5 maintenant partie 1 : la sémantique
HTML5 maintenant partie 1 : la sémantiqueHTML5 maintenant partie 1 : la sémantique
HTML5 maintenant partie 1 : la sémantique
 
Confoo - 2012-02-27 au 2012-02-28 - HTML5 workshop
Confoo - 2012-02-27 au 2012-02-28 - HTML5 workshopConfoo - 2012-02-27 au 2012-02-28 - HTML5 workshop
Confoo - 2012-02-27 au 2012-02-28 - HTML5 workshop
 
technologie web - part2
technologie web - part2technologie web - part2
technologie web - part2
 
Conception Web Avec Dreamweaver
Conception Web Avec DreamweaverConception Web Avec Dreamweaver
Conception Web Avec Dreamweaver
 
Beautiful CSS : Structurer, documenter, maintenir
Beautiful CSS : Structurer, documenter, maintenirBeautiful CSS : Structurer, documenter, maintenir
Beautiful CSS : Structurer, documenter, maintenir
 
Découverte HTML5/CSS3
Découverte HTML5/CSS3Découverte HTML5/CSS3
Découverte HTML5/CSS3
 
Développement Web sur iPhone (iPhone+iPad DevCamp Québec)
Développement Web sur iPhone (iPhone+iPad DevCamp Québec)Développement Web sur iPhone (iPhone+iPad DevCamp Québec)
Développement Web sur iPhone (iPhone+iPad DevCamp Québec)
 

Internationalisation du Front

  • 1. Internationalisation du Front Yannick Croissant Paris Web 2010 – 14-16 octobre 2010
  • 2. Présentation Yannick Croissant • Développeur Front dans l’Agence Interactive de TF1 • S’occupe de toute la partie front de différents sites d’équipes sportives. •
  • 4. Internationalisation du côté de l’intégrateur
  • 5. Différents éléments concernés : • Templates HTML • Images • CSS • Javascript
  • 7. Utilisez les capacités de vos outils
  • 8. CMS Wordpress __('Hello World') Framework Django {% trans 'Hello World' %} Language PHP _('Hello World')
  • 9. Tous utilisent la même chose pour fonctionner
  • 11. Gettext index.html article.html archives.html monsite.pot
  • 12. CMS Wordpress __('Hello World') Framework Django {% trans 'Hello World' %} Language PHP _('Hello World')
  • 13. Générer le fichier .pot • Wordpress: i18n Tools http://codex.wordpress.org/I18n_for_WordPress_Developers • Django: django-admin.py makemessages http://docs.djangoproject.com/en/1.2/topics/i18n/localization • PHP: xgettext http://gettext.sourceforge.net/ Etc...
  • 14. Mes petits outils à moi AutoGetText http://github.com/Country/Utils
  • 15. Mes petits outils à moi AutoGetText http://github.com/Country/Utils
  • 16. Gettext monsite.pot fr-FR.mo en-US.mo
  • 17. Template source <!DOCTYPE html> <html lang="{% trans 'lang' %}"> <head> <meta charset="utf-8" /> <title>{% trans 'site-title' %}</title> [...]
  • 18. Site français <!DOCTYPE html> <html lang="fr-FR"> <head> <meta charset="utf-8" /> <title>Mon site</title> [...]
  • 19. Site anglais <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8" /> <title>My Website</title> [...]
  • 21. Vos images contiennent elles aussi du texte
  • 24. Découpe • Sprites
  • 25. Découpe • Sprites • Horizontaux
  • 26. Découpe • Sprites • Horizontaux • Verticaux
  • 27. Découpe • Sprites • Horizontaux • Verticaux • Uniques
  • 28. Découpe • Sprites • Horizontaux • Verticaux • Uniques • Formats
  • 29. Découpe • Sprites • Horizontaux • Verticaux • Uniques • Formats • GIF
  • 30. Découpe • Sprites • Horizontaux • Verticaux • Uniques • Formats • GIF • PNG8
  • 31. Découpe • Sprites • Horizontaux • Verticaux • Uniques • Formats • GIF • PNG8 • PNG32
  • 32. Découpe • Sprites • Horizontaux • Verticaux • Uniques • Formats • GIF • PNG8 • PNG32 • JPEG
  • 33. Découpe • Sprites • Horizontaux • Verticaux • Uniques • Formats • GIF • PNG8 • PNG32 • JPEG
  • 34. Centralisez vos textes http://s.lnb.fr/lnb/file/assets/image/generic/titles.png
  • 35. Centralisez vos textes (et surtout pas comme ça) http://www.olweb.fr/image/generic/menu.png
  • 36. Centralisez vos textes (et surtout pas comme ça) http://www.olweb.fr/image/generic/menu.png
  • 41. On peut commencer à traduire
  • 42. On peut commencer à traduire fr-FR
  • 43. On peut commencer à traduire fr-FR en-US
  • 44. On peut commencer à traduire fr-FR en-US Vos sprites doivent être identiques (enfin, si possible)
  • 45. CSS
  • 46. Eléments à traduire • Peu de changements. • On a déjà fait le plus gros du travail: templates et images.
  • 47. .button { background:url(button-fr-FR.png) no-repeat -25px -30px; height:20px; margin:0 0 0 10px; width:125px; }
  • 48. <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8" /> <title>My Website</title> [...]
  • 49. <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8" /> <title>My Website</title> [...]
  • 50. .button { background:url(button-fr-FR.png) no-repeat -25px -30px; height:20px; margin:0 0 0 10px; width:125px; } [lang='en-US'] .button { background-image:url(button-en-US.png); }
  • 52. <!DOCTYPE html> <html lang="ar-AR" dir="rtl"> <head> <meta charset="utf-8" /> <title>‫/<ﺍﺧﺘﺒﺎﺭ‬title> [...]
  • 53. .button { background:url(button-fr-FR.png) no-repeat -25px -30px; height:20px; margin:0 0 0 10px; width:125px; } [lang='en-US'] .button { background-image:url(button-en-US.png); } [lang='ar-AR'] .button { background-image:url(button-ar-AR.png); width:100px; } [dir='ltr'] .button { margin:0 10px 0 0; }
  • 55. Fonctionne partout (Sauf sous IE6)
  • 56. Si vous devez encore supporter IE6
  • 57. Si vous devez encore supporter IE6 Utilisez des class sur votre <body> <body class="lang-ar-AR dir-rtl">
  • 58. Si vous devez encore supporter IE6 Utilisez des class sur votre <body> <body class="lang-{% trans 'lang' %} dir-{% trans 'dir' %}">
  • 59. Si vous devez encore supporter IE6 Utilisez des class sur votre <body> <body class="lang-{% trans 'lang' %} dir-{% trans 'dir' %}"> Votre CSS deviendra alors: .lang-ar-AR .button { ... } .dir-rtl .button { ... }
  • 60. Un ou plusieurs fichiers CSS ?
  • 61. Un ou plusieurs fichiers CSS ? • Dépend du projet.
  • 62. Un ou plusieurs fichiers CSS ? • Dépend du projet. • 2 ou 3 langues: 1 seul fichier suffit généralement.
  • 63. Un ou plusieurs fichiers CSS ? • Dépend du projet. • 2 ou 3 langues: 1 seul fichier suffit généralement. • + de langues et/ou beaucoup de changements: penser à diviser en plusieurs fichiers.
  • 64. Un ou plusieurs fichiers CSS ? • Dépend du projet. • 2 ou 3 langues: 1 seul fichier suffit généralement. • + de langues et/ou beaucoup de changements: penser à diviser en plusieurs fichiers. <link rel="stylesheet" href="css/global.css" /> <link rel="stylesheet" href="css/en-US.css" />
  • 65. Dans le cas d’une division en plusieurs fichiers: Plus besoin d’utiliser le sélecteur sur l’attribut lang global.css : .button { background:url(button-fr-FR.png) no-repeat -25px -30px; height:20px; margin:0 0 0 10px; width:125px; } en-US.css : .button { background-image:url(button-en-US.png); }
  • 67. De plus en plus de contenu généré par Javascript
  • 69. MooTools.lang.set('fr-FR', 'Example', { helloWorld: 'Bonjour Monde' }); MooTools.lang.set('en-US', 'Example', { helloWorld: 'Hello World' }); MooTools.lang.setLanguage(document.documentElement.lang); alert(MooTools.lang.get('Example', 'helloWorld')); http://www.mootools.net/docs/more/Core/Lang
  • 70. MooTools.lang.set('fr-FR', 'Example', { helloWorld: 'Bonjour Monde' }); MooTools.lang.set('en-US', 'Example', { helloWorld: 'Hello World' }); MooTools.lang.setLanguage(document.documentElement.lang); alert(MooTools.lang.get('Example', 'helloWorld')); http://www.mootools.net/docs/more/Core/Lang
  • 71. MooTools.lang.set('fr-FR', 'Example', { helloWorld: 'Bonjour Monde' }); MooTools.lang.set('en-US', 'Example', { helloWorld: 'Hello World' }); MooTools.lang.setLanguage(document.documentElement.lang); alert(MooTools.lang.get('Example', 'helloWorld')); http://www.mootools.net/docs/more/Core/Lang
  • 72. MooTools.lang.set('fr-FR', 'Example', { helloWorld: 'Bonjour Monde' }); MooTools.lang.set('en-US', 'Example', { helloWorld: 'Hello World' }); MooTools.lang.setLanguage(document.documentElement.lang); alert(MooTools.lang.get('Example', 'helloWorld')); http://www.mootools.net/docs/more/Core/Lang
  • 73. MooTools.lang.set('fr-FR', 'Example', { helloWorld: 'Bonjour Monde' }); MooTools.lang.set('en-US', 'Example', { helloWorld: 'Hello World' }); MooTools.lang.setLanguage(document.documentElement.lang); alert(MooTools.lang.get('Example', 'helloWorld')); http://www.mootools.net/docs/more/Core/Lang
  • 74. MooTools.lang.set('fr-FR', 'Example', { helloWorld: 'Bonjour Monde' }); MooTools.lang.set('en-US', 'Example', { helloWorld: 'Hello World' }); MooTools.lang.setLanguage(document.documentElement.lang); alert(MooTools.lang.get('Example', 'helloWorld')); http://www.mootools.net/docs/more/Core/Lang
  • 75. MooTools.lang.set('fr-FR', 'Example', { helloWorld: 'Bonjour Monde' }); MooTools.lang.set('en-US', 'Example', { helloWorld: 'Hello World' }); MooTools.lang.setLanguage(document.documentElement.lang); alert(MooTools.lang.get('Example', 'helloWorld')); http://www.mootools.net/docs/more/Core/Lang
  • 77. • Pas de support natif
  • 78. • Pas de support natif • Plugin
  • 79. • Pas de support natif • Plugin: jQuery i18n de Bryan Berry http://github.com/bryanwb/jquery-18n
  • 80. $.i18n['en-US'] = { strings: { helloWorld: 'Hello World' } }; $.i18n['fr-FR'] = { strings: { helloWorld: 'Bonjour Monde' } }; $.i18n.setLocale(document.documentElement.lang); alert($.i18n('helloWorld'));
  • 81. $.i18n['en-US'] = { strings: { helloWorld: 'Hello World' } }; $.i18n['fr-FR'] = { strings: { helloWorld: 'Bonjour Monde' } }; $.i18n.setLocale(document.documentElement.lang); alert($.i18n('helloWorld'));
  • 82. $.i18n['en-US'] = { strings: { helloWorld: 'Hello World' } }; $.i18n['fr-FR'] = { strings: { helloWorld: 'Bonjour Monde' } }; $.i18n.setLocale(document.documentElement.lang); alert($.i18n('helloWorld'));
  • 83. $.i18n['en-US'] = { strings: { helloWorld: 'Hello World' } }; $.i18n['fr-FR'] = { strings: { helloWorld: 'Bonjour Monde' } }; $.i18n.setLocale(document.documentElement.lang); alert($.i18n('helloWorld'));
  • 84. $.i18n['en-US'] = { strings: { helloWorld: 'Hello World' } }; $.i18n['fr-FR'] = { strings: { helloWorld: 'Bonjour Monde' } }; $.i18n.setLocale(document.documentElement.lang); alert($.i18n('helloWorld'));
  • 85. $.i18n['en-US'] = { strings: { helloWorld: 'Hello World' } }; $.i18n['fr-FR'] = { strings: { helloWorld: 'Bonjour Monde' } }; $.i18n.setLocale(document.documentElement.lang); alert($.i18n('helloWorld'));
  • 86. $.i18n['en-US'] = { strings: { helloWorld: 'Hello World' } }; $.i18n['fr-FR'] = { strings: { helloWorld: 'Bonjour Monde' } }; $.i18n.setLocale(document.documentElement.lang); alert($.i18n('helloWorld'));
  • 88. var i18n = { 'en-US': { helloWorld: 'Hello World' }, 'fr-FR': { helloWorld: 'Bonjour Monde' } }; var currentLanguage = document.documentElement.lang; alert(i18n[currentLanguage].helloWorld);
  • 89. var i18n = { 'en-US': { helloWorld: 'Hello World' }, 'fr-FR': { helloWorld: 'Bonjour Monde' } }; var currentLanguage = document.documentElement.lang; alert(i18n[currentLanguage].helloWorld);
  • 90. var i18n = { 'en-US': { helloWorld: 'Hello World' }, 'fr-FR': { helloWorld: 'Bonjour Monde' } }; var currentLanguage = document.documentElement.lang; alert(i18n[currentLanguage].helloWorld);
  • 91. var i18n = { 'en-US': { helloWorld: 'Hello World' }, 'fr-FR': { helloWorld: 'Bonjour Monde' } }; var currentLanguage = document.documentElement.lang; alert(i18n[currentLanguage].helloWorld);
  • 92. var i18n = { 'en-US': { helloWorld: 'Hello World' }, 'fr-FR': { helloWorld: 'Bonjour Monde' } }; var currentLanguage = document.documentElement.lang; alert(i18n[currentLanguage].helloWorld);
  • 93. var i18n = { 'en-US': { helloWorld: 'Hello World' }, 'fr-FR': { helloWorld: 'Bonjour Monde' } }; var currentLanguage = document.documentElement.lang; alert(i18n[currentLanguage].helloWorld);
  • 94. var i18n = { 'en-US': { helloWorld: 'Hello World' }, 'fr-FR': { helloWorld: 'Bonjour Monde' } }; var currentLanguage = document.documentElement.lang; alert(i18n[currentLanguage].helloWorld);
  • 95. var i18n = { 'en-US': { helloWorld: 'Hello World' }, 'fr-FR': { helloWorld: 'Bonjour Monde' } }; var currentLanguage = document.documentElement.lang; alert(i18n[currentLanguage].helloWorld);
  • 96. Mes petits outils à moi (2) AutoGetText JS http://github.com/Country/Utils
  • 97. Mes petits outils à moi (2) AutoGetText JS http://github.com/Country/Utils
  • 99. Solution 1 <script src="js/framework.js"></script> <script src="js/lang-{% trans 'lang' %}.js"></script> <script src="js/scripts.js"></script>
  • 100. Solution 2 <script src="js/global-{% trans 'lang' %}.js"></script>
  • 101. Solution 2 <script src="js/global-{% trans 'lang' %}.js"></script> global-fr-FR.js = framework.js + lang-fr-FR.js + scripts.js global-en-US.js = framework.js + lang-en-US.js + scripts.js etc...
  • 104. Merci ! http://github.com/Country * http://yannick.cr http://twitter.com/yannickc Des questions ? * Un peu mort, mais j’y travaille

Notes de l'éditeur