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

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Ö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/