SlideShare a Scribd company logo
1 of 46
Download to read offline
Översättning i Django
         Mikael Moutakis
    mikaelmoutakis@gmail.com
Internationalization
       i18n
Localization
   L10n
Vad?
Varför?
Det minst viktiga
    först ...
. . . mjukvaran!
Hur funkar tekniken?

1. Märk ut pythonkod och templatekod
2. Extrahera
3. Översätt
4. Kompilera och installera
5. Starta om server
... Steg 0.
use_I18N=True

MIDDLEWARE_CLASSES = (
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.locale.LocaleMiddleware',
   'django.middleware.common.CommonMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS += (
	

 “django.core.context_processors.i18n”,
)

LANGUAGE_COOKIE_NAME=quot;django_languagequot;
LANGUAGE_CODE = 'sv'
1.a Märk ut pythonkod

from django.utils.translation import ugettext_lazy as _


class Calendar(models.Model):
  color = models.CharField(_(quot;colorquot;))
1.a Märk ut pythonkod

• ugettext_noop
• ugettext
• ugettext_lazy
• ungettext
• ungettext_lazy
Vara lat?

• ugettext_lazy för model.py
 • När textvärdet hämtas
• ugettext för resten
 • När funktionen anropas
ungettext och
                  ungettext_lazy
from django.utils.translation import ungettext

def hello_world(request, count):

  page = ungettext('there is %(count)d object', 'there are %(count)d objects', count) % {

      'count': count,

  }

  return HttpResponse(page)
1.b templatekod
{% load i18n %}
...
h1{% trans “Kanelbulle” %}/h1
p{% blocktrans %}Hej, tomtegubbar slå i
glasen, n
och låt oss lustiga vara.
{% endblocktrans %}/p
1.b templatekod

h1{% trans “Kanelbulle” %}/h1
h1{% trans “Kanelbulle” noop %}/h1
1.b templatekod

p{% blocktrans with publ_date|date as
local_date %}
Idag är det {{local_date}}. Mac rular fett.
{% endblocktrans%}/p
1.b templatekod
p{% blocktrans with publ_date|date as
local_date and spam as skinka%}
Idag är det den {{local_date}}. Mac rular fett.
{{skinka}}, {{skinka}}, {{skinka}}
{% endblocktrans%}/p
1.b templatekod
{% blocktrans count list|length as counter %}
There is only one {{ name }} object.
{% plural %}
There are {{ counter }} {{ name }} objects.
{% endblocktrans %}
2. Extrahera texten
cd /path/to/myproject
(cd /path/to/myapp)
django-admin.py makemessages -l sv
django-admin.py makemessages -l en
django-admin.py makemessages -l de
Mappstruktur
2. Extrahera texten
cd /path/to/myproject
(cd /path/to/myapp)
mkdir -p locale/sv/LC_MESSAGES
django-admin.py makemessages -l sv
django.po
msgid quot;quot;
msgstr quot;quot;
quot;Project-Id-Version: nquot;
quot;Report-Msgid-Bugs-To: nquot;
quot;POT-Creation-Date: 2008-10-12 19:21+0200nquot;
quot;PO-Revision-Date: 2009-04-18 19:25+0100nquot;
quot;Last-Translator: Mikael Moutakis
mikaelmoutakis@gmail.comnquot;
quot;Language-Team: nquot;
quot;MIME-Version: 1.0nquot;
quot;Content-Type: text/plain; charset=UTF-8nquot;
quot;Content-Transfer-Encoding: 8bitnquot;

#: django_admin_overrides/admin/base.html:25
msgid quot;Welcome,quot;
msgstr quot;Välkommen,quot;
poEdit
Vilket språk?

1. Nyckeln django_language i user session
2. Cookie django_language
3. Accept-Language HTTP header
4. LANGUAGE_CODE i settings.py
Vilket språk? (2)

ugettext = lambda s: s
LANGUAGES = (
    ('sv', ugettext('Swedish')),
    ('en', ugettext('English')),
)
Vad har jag missat?
• olika sajter för olika länder
                                  !
                 M
• string_concat
               F
• @allow_lazy
              T
             R
• set_language redirect view
• översättning av javascript
• Windows
Nu den svåra biten . . .
ga
          lli
       pi
Nu den svåra biten . . .
Tänk på sammanhanget!
Kom ihåg denna bild!
Vad fan menar han?
Tillbaka till Google
       Docs
Men vad ser
         översättaren?
New
Upload
All items
Owned by me
Opened by me
Starred
Hidden
Trash
Men vad ser
         översättaren?
New            Ny/Nytt/Nya/Färsk/Färska?
Upload         Ladda upp/Uppladdning?
All items      Alla saker/punkter/nummer
Owned by me    Ägd/ägda av mig
Opened by me   Öppnad/öppnade av mig
Starred        Stjärnad? Framträdde?
Hidden         Gömd/Gömda
Trash          Smörja/struntprat/slödder
Lösning? Ge tips!
New [document]
Upload [a document]
All items [ie documents]
[documents] Owned by me
[documents] Opened by me
Starred [documents]
Hidden [documents]
Trash [trashcan]
Datum, typografi, mm

• Idag är det 2009-04-20. Känner ni till
  “Django”?
• Today is 20/04/09. Do you know “Django”?
• Today is 04/20/09. Do you know “Django”?
Datum, typografi, mm

• Heute ist 20.04.09. Kennt ihr „Django”?
• Σήμερα είναι 20.04.09. Γνωρίζετε το
    «Django»;
•
Datum, typografi, mm
{% blocktrans with publ_date.year as year and
publ_date.month as month and publ_date.day as day
%}
Idag är det {{year}}-{{month}}-{{day}}.
{% endblocktrans %}
Skrivriktning?
Sammanfattning

• Tänk på sammanhanget
• Tänk på typografin
• Olika sätt att skriva datum
• Olika längd på texten
• Skrivriktning
Länkar
•   http://www.norstedtsord.se/oversattning/
    engelska/

•   http://docs.djangoproject.com/en/dev/topics/i18n/
    #topics-i18n

•   http://en.wikipedia.org/wiki/
    Internationalization_and_localization

•   http://en.wikipedia.org/wiki/Calendar_date
Fler länkar


•   http://www.onemanga.com/Bakuman/

•   http://www.mangakailund.org/
Tack för
uppmärksamheten

More Related Content

Viewers also liked

Alfaro, Zikoinen Paradisua
Alfaro, Zikoinen ParadisuaAlfaro, Zikoinen Paradisua
Alfaro, Zikoinen Paradisuaanalarranaga
 
Tecnofilo e a informatização da educação
Tecnofilo e a informatização da educaçãoTecnofilo e a informatização da educação
Tecnofilo e a informatização da educaçãoJessicaagostinho
 
Mas Sila Brenda 010409
Mas Sila Brenda 010409Mas Sila Brenda 010409
Mas Sila Brenda 010409profeoua
 
CulturaItalia - Da MINERVA e MICHAEL a CulturaItalia: la partecipazione itali...
CulturaItalia - Da MINERVA e MICHAEL a CulturaItalia: la partecipazione itali...CulturaItalia - Da MINERVA e MICHAEL a CulturaItalia: la partecipazione itali...
CulturaItalia - Da MINERVA e MICHAEL a CulturaItalia: la partecipazione itali...CulturaItalia
 
Astrid proyecto de vida
Astrid proyecto de vidaAstrid proyecto de vida
Astrid proyecto de vidakissforyou9e
 
Otwarte modele komunikowania w nauce i edukacji
Otwarte modele komunikowania w nauce i edukacjiOtwarte modele komunikowania w nauce i edukacji
Otwarte modele komunikowania w nauce i edukacjiKOED
 
Mobile Learning Centre
Mobile Learning CentreMobile Learning Centre
Mobile Learning CentreWeb Umpire
 
Cuadro de valoracion
Cuadro de valoracionCuadro de valoracion
Cuadro de valoracionkissforyou9e
 
願景2020世界咖啡館
願景2020世界咖啡館願景2020世界咖啡館
願景2020世界咖啡館Yoren Chang
 
Efectos de las drogas
Efectos de las drogasEfectos de las drogas
Efectos de las drogasflorlena
 
Home (2008 07 & 08)
Home (2008 07 & 08)Home (2008 07 & 08)
Home (2008 07 & 08)waldjarda
 
guangxi
guangxiguangxi
guangxicclu
 
Segundo relatório de missoes bruno da montanha nordeste maranhao brasil
Segundo relatório de missoes bruno da montanha nordeste maranhao brasilSegundo relatório de missoes bruno da montanha nordeste maranhao brasil
Segundo relatório de missoes bruno da montanha nordeste maranhao brasilBruno Da Montanha
 

Viewers also liked (19)

Alfaro, Zikoinen Paradisua
Alfaro, Zikoinen ParadisuaAlfaro, Zikoinen Paradisua
Alfaro, Zikoinen Paradisua
 
Tecnofilo e a informatização da educação
Tecnofilo e a informatização da educaçãoTecnofilo e a informatização da educação
Tecnofilo e a informatização da educação
 
6 John Dalton
6 John Dalton6 John Dalton
6 John Dalton
 
Mas Sila Brenda 010409
Mas Sila Brenda 010409Mas Sila Brenda 010409
Mas Sila Brenda 010409
 
Feliz dimthi!!!
Feliz dimthi!!!Feliz dimthi!!!
Feliz dimthi!!!
 
Windosalamexicana
WindosalamexicanaWindosalamexicana
Windosalamexicana
 
Grand paper ismud
Grand paper ismudGrand paper ismud
Grand paper ismud
 
CulturaItalia - Da MINERVA e MICHAEL a CulturaItalia: la partecipazione itali...
CulturaItalia - Da MINERVA e MICHAEL a CulturaItalia: la partecipazione itali...CulturaItalia - Da MINERVA e MICHAEL a CulturaItalia: la partecipazione itali...
CulturaItalia - Da MINERVA e MICHAEL a CulturaItalia: la partecipazione itali...
 
Gatti Bw
Gatti   BwGatti   Bw
Gatti Bw
 
Astrid proyecto de vida
Astrid proyecto de vidaAstrid proyecto de vida
Astrid proyecto de vida
 
Otwarte modele komunikowania w nauce i edukacji
Otwarte modele komunikowania w nauce i edukacjiOtwarte modele komunikowania w nauce i edukacji
Otwarte modele komunikowania w nauce i edukacji
 
wikimates 2
wikimates 2wikimates 2
wikimates 2
 
Mobile Learning Centre
Mobile Learning CentreMobile Learning Centre
Mobile Learning Centre
 
Cuadro de valoracion
Cuadro de valoracionCuadro de valoracion
Cuadro de valoracion
 
願景2020世界咖啡館
願景2020世界咖啡館願景2020世界咖啡館
願景2020世界咖啡館
 
Efectos de las drogas
Efectos de las drogasEfectos de las drogas
Efectos de las drogas
 
Home (2008 07 & 08)
Home (2008 07 & 08)Home (2008 07 & 08)
Home (2008 07 & 08)
 
guangxi
guangxiguangxi
guangxi
 
Segundo relatório de missoes bruno da montanha nordeste maranhao brasil
Segundo relatório de missoes bruno da montanha nordeste maranhao brasilSegundo relatório de missoes bruno da montanha nordeste maranhao brasil
Segundo relatório de missoes bruno da montanha nordeste maranhao brasil
 

Similar to Översättning av django-program

Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...Jazkarta, Inc.
 
Twiggy - let's get our widget on!
Twiggy - let's get our widget on!Twiggy - let's get our widget on!
Twiggy - let's get our widget on!Elliott Kember
 
WCRI 2015 I18N L10N
WCRI 2015 I18N L10NWCRI 2015 I18N L10N
WCRI 2015 I18N L10NDave McHale
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Byrne Reese
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceJesse Vincent
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Developmentwolframkriesing
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 
How Not To Code Flex Applications
How Not To Code Flex ApplicationsHow Not To Code Flex Applications
How Not To Code Flex Applicationsjeff tapper
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails IntroductionEric Weimer
 
Variables & Expressions
Variables & ExpressionsVariables & Expressions
Variables & ExpressionsRich Price
 
Hacking Movable Type Training - Day 1
Hacking Movable Type Training - Day 1Hacking Movable Type Training - Day 1
Hacking Movable Type Training - Day 1Byrne Reese
 
Pragmatics of Declarative Ajax
Pragmatics of Declarative AjaxPragmatics of Declarative Ajax
Pragmatics of Declarative Ajaxdavejohnson
 
Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as codeJulian Simpson
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Librariesjeresig
 

Similar to Översättning av django-program (20)

Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
 
Twiggy - let's get our widget on!
Twiggy - let's get our widget on!Twiggy - let's get our widget on!
Twiggy - let's get our widget on!
 
Juggling
JugglingJuggling
Juggling
 
WCRI 2015 I18N L10N
WCRI 2015 I18N L10NWCRI 2015 I18N L10N
WCRI 2015 I18N L10N
 
Practical Groovy DSL
Practical Groovy DSLPractical Groovy DSL
Practical Groovy DSL
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
 
Week8
Week8Week8
Week8
 
Preon (J-Fall 2008)
Preon (J-Fall 2008)Preon (J-Fall 2008)
Preon (J-Fall 2008)
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Development
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
How Not To Code Flex Applications
How Not To Code Flex ApplicationsHow Not To Code Flex Applications
How Not To Code Flex Applications
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails Introduction
 
Variables & Expressions
Variables & ExpressionsVariables & Expressions
Variables & Expressions
 
Hacking Movable Type Training - Day 1
Hacking Movable Type Training - Day 1Hacking Movable Type Training - Day 1
Hacking Movable Type Training - Day 1
 
Pragmatics of Declarative Ajax
Pragmatics of Declarative AjaxPragmatics of Declarative Ajax
Pragmatics of Declarative Ajax
 
20 Jo P Aug 08
20 Jo P Aug 0820 Jo P Aug 08
20 Jo P Aug 08
 
Smarty
SmartySmarty
Smarty
 
Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as code
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 

Översättning av django-program

  • 1. Översättning i Django Mikael Moutakis mikaelmoutakis@gmail.com
  • 6. Det minst viktiga först ...
  • 7. . . . mjukvaran!
  • 8. Hur funkar tekniken? 1. Märk ut pythonkod och templatekod 2. Extrahera 3. Översätt 4. Kompilera och installera 5. Starta om server
  • 9. ... Steg 0. use_I18N=True MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', ) TEMPLATE_CONTEXT_PROCESSORS += ( “django.core.context_processors.i18n”, ) LANGUAGE_COOKIE_NAME=quot;django_languagequot; LANGUAGE_CODE = 'sv'
  • 10. 1.a Märk ut pythonkod from django.utils.translation import ugettext_lazy as _ class Calendar(models.Model): color = models.CharField(_(quot;colorquot;))
  • 11. 1.a Märk ut pythonkod • ugettext_noop • ugettext • ugettext_lazy • ungettext • ungettext_lazy
  • 12. Vara lat? • ugettext_lazy för model.py • När textvärdet hämtas • ugettext för resten • När funktionen anropas
  • 13. ungettext och ungettext_lazy from django.utils.translation import ungettext def hello_world(request, count): page = ungettext('there is %(count)d object', 'there are %(count)d objects', count) % { 'count': count, } return HttpResponse(page)
  • 14. 1.b templatekod {% load i18n %} ... h1{% trans “Kanelbulle” %}/h1 p{% blocktrans %}Hej, tomtegubbar slå i glasen, n och låt oss lustiga vara. {% endblocktrans %}/p
  • 15. 1.b templatekod h1{% trans “Kanelbulle” %}/h1 h1{% trans “Kanelbulle” noop %}/h1
  • 16. 1.b templatekod p{% blocktrans with publ_date|date as local_date %} Idag är det {{local_date}}. Mac rular fett. {% endblocktrans%}/p
  • 17. 1.b templatekod p{% blocktrans with publ_date|date as local_date and spam as skinka%} Idag är det den {{local_date}}. Mac rular fett. {{skinka}}, {{skinka}}, {{skinka}} {% endblocktrans%}/p
  • 18. 1.b templatekod {% blocktrans count list|length as counter %} There is only one {{ name }} object. {% plural %} There are {{ counter }} {{ name }} objects. {% endblocktrans %}
  • 19. 2. Extrahera texten cd /path/to/myproject (cd /path/to/myapp) django-admin.py makemessages -l sv django-admin.py makemessages -l en django-admin.py makemessages -l de
  • 21. 2. Extrahera texten cd /path/to/myproject (cd /path/to/myapp) mkdir -p locale/sv/LC_MESSAGES django-admin.py makemessages -l sv
  • 22. django.po msgid quot;quot; msgstr quot;quot; quot;Project-Id-Version: nquot; quot;Report-Msgid-Bugs-To: nquot; quot;POT-Creation-Date: 2008-10-12 19:21+0200nquot; quot;PO-Revision-Date: 2009-04-18 19:25+0100nquot; quot;Last-Translator: Mikael Moutakis mikaelmoutakis@gmail.comnquot; quot;Language-Team: nquot; quot;MIME-Version: 1.0nquot; quot;Content-Type: text/plain; charset=UTF-8nquot; quot;Content-Transfer-Encoding: 8bitnquot; #: django_admin_overrides/admin/base.html:25 msgid quot;Welcome,quot; msgstr quot;Välkommen,quot;
  • 24. Vilket språk? 1. Nyckeln django_language i user session 2. Cookie django_language 3. Accept-Language HTTP header 4. LANGUAGE_CODE i settings.py
  • 25. Vilket språk? (2) ugettext = lambda s: s LANGUAGES = ( ('sv', ugettext('Swedish')), ('en', ugettext('English')), )
  • 26. Vad har jag missat? • olika sajter för olika länder ! M • string_concat F • @allow_lazy T R • set_language redirect view • översättning av javascript • Windows
  • 27. Nu den svåra biten . . .
  • 28. ga lli pi Nu den svåra biten . . .
  • 32.
  • 33.
  • 34.
  • 36. Men vad ser översättaren? New Upload All items Owned by me Opened by me Starred Hidden Trash
  • 37. Men vad ser översättaren? New Ny/Nytt/Nya/Färsk/Färska? Upload Ladda upp/Uppladdning? All items Alla saker/punkter/nummer Owned by me Ägd/ägda av mig Opened by me Öppnad/öppnade av mig Starred Stjärnad? Framträdde? Hidden Gömd/Gömda Trash Smörja/struntprat/slödder
  • 38. Lösning? Ge tips! New [document] Upload [a document] All items [ie documents] [documents] Owned by me [documents] Opened by me Starred [documents] Hidden [documents] Trash [trashcan]
  • 39. Datum, typografi, mm • Idag är det 2009-04-20. Känner ni till “Django”? • Today is 20/04/09. Do you know “Django”? • Today is 04/20/09. Do you know “Django”?
  • 40. Datum, typografi, mm • Heute ist 20.04.09. Kennt ihr „Django”? • Σήμερα είναι 20.04.09. Γνωρίζετε το «Django»; •
  • 41. Datum, typografi, mm {% blocktrans with publ_date.year as year and publ_date.month as month and publ_date.day as day %} Idag är det {{year}}-{{month}}-{{day}}. {% endblocktrans %}
  • 43. Sammanfattning • Tänk på sammanhanget • Tänk på typografin • Olika sätt att skriva datum • Olika längd på texten • Skrivriktning
  • 44. Länkar • http://www.norstedtsord.se/oversattning/ engelska/ • http://docs.djangoproject.com/en/dev/topics/i18n/ #topics-i18n • http://en.wikipedia.org/wiki/ Internationalization_and_localization • http://en.wikipedia.org/wiki/Calendar_date
  • 45. Fler länkar • http://www.onemanga.com/Bakuman/ • http://www.mangakailund.org/