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

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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
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
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

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 ...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
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
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

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