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

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

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