18 Оттенков I18n

18 Оттенков I18n
Localization Internationalization
catgets VS gettext
1995
[language[_territory][.codeset][@modifier]]
Locale
en_GB.UTF-8@variant
Messages
Dates
Numbers
Currency
en_GB
Locale
More about Localization
• Images
• Sound
• Video
• Cultural perception
• Taxes
gettext features
• Messages
• Plural forms
• Context
Django I18n tools
• gettext
• Formats
• Timezones
I18n features
workflow
Me InterpreterLocalized
Product
P
O
M
O
from django.utils.translation import gettext_noop as _noop
from django.utils.translation import gettext as _
{
_noop(”Winnie rhyme”):
_("It's a very funny thought that, if Bears were Bees,"
"They'd build their nests at the bottom of trees."
"And that being so (if the Bees were Bears),"
"We shouldn't have to climb up all these stairs.”)
}
✪ python manage.py makemessages
Portable Objects
PO files
#: main.py:3
msgid ""
"It's a very funny thought that, if Bears were Bees,"
"They'd build their nests at the bottom of trees."
"And that being so (if the Bees were Bears),"
"We shouldn't have to climb up all these stairs.”
msgstr ""
Pootle Server
18 Оттенков I18n
Custom Solution
http://rannts.ru/meetups/1/l10n/
Legacy?
Customer?
#: main.py:3
msgid ""
"It's a very funny thought that, if Bears were Bees,"
"They'd build their nests at the bottom of trees."
"And that being so (if the Bees were Bears),"
"We shouldn't have to climb up all these stairs.”
msgstr ""
"Если б мишки были пчёлами, то они бы нипочём, никогда ”
"и не подумали так высо́ко строить дом… Ой!"
✪ python manage.py compilemessages
18 Оттенков I18n
Provide more context
@classmethod
def get_table_caption(cls):
# Translators: Taxable or Non-Taxable Donations
return cls.prefix + _(' Donations')
#: Translators: Taxable or Non-Taxable Donations
#: source.py:3
msgid ""
"Donations"
msgstr ""
source
PO
Avoid dynamic string creating
@property
def prefix(self):
if self.gov_state in ['CA', 'TX', 'FL']:
# Translators: Taxable Donations
return _('Taxable')
else:
# Translators: Non-Taxable Donations
return _('Non-Taxable')
def get_table_caption(self):
# Translators: Taxable or Non-Taxable Donations
return self.prefix + _('Donations'))
Words sequence cannot be changed
What if nothing to do?
Insert right to the PO files
python-babel
Flask-Babel
Same features. Both uses gettext.
babel-django
Python gettext standard library
GNU gettext API
import gettext
gettext.gettext('EOD Report')
More – pymorphy – pymorphy2
Русский, Белорусский, Украинский.
Морфологический анализ.
(род, число, падеж)
pymorphy-django
mystem
Yandex
Морфологический анализ
cli интерфейс
Informative Links
• History of GNU gettext
https://www.gnu.org/software/gettext/manual/html_node/gettext_219.html#History
https://www.w3.org/International/questions/qa-i18n.ru.php
1 of 25

Recommended

Trees in RDBs by
Trees in RDBsTrees in RDBs
Trees in RDBsAleksey Kutepov
435 views22 slides
Gevent rabbit rpc by
Gevent rabbit rpcGevent rabbit rpc
Gevent rabbit rpcAleksandr Mokrov
496 views49 slides
Cooking pies with Celery by
Cooking pies with CeleryCooking pies with Celery
Cooking pies with CeleryAleksandr Mokrov
493 views35 slides
Sql Antipatterns Strike Back by
Sql Antipatterns Strike BackSql Antipatterns Strike Back
Sql Antipatterns Strike BackKarwin Software Solutions LLC
289.2K views250 slides
ChatGPT and the Future of Work - Clark Boyd by
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
28K views69 slides
Getting into the tech field. what next by
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
6.6K views22 slides

More Related Content

Recently uploaded

Plant Design Report-Oil Refinery.pdf by
Plant Design Report-Oil Refinery.pdfPlant Design Report-Oil Refinery.pdf
Plant Design Report-Oil Refinery.pdfSafeen Yaseen Ja'far
9 views10 slides
Créativité dans le design mécanique à l’aide de l’optimisation topologique by
Créativité dans le design mécanique à l’aide de l’optimisation topologiqueCréativité dans le design mécanique à l’aide de l’optimisation topologique
Créativité dans le design mécanique à l’aide de l’optimisation topologiqueLIEGE CREATIVE
8 views84 slides
REACTJS.pdf by
REACTJS.pdfREACTJS.pdf
REACTJS.pdfArthyR3
37 views16 slides
Unlocking Research Visibility.pdf by
Unlocking Research Visibility.pdfUnlocking Research Visibility.pdf
Unlocking Research Visibility.pdfKhatirNaima
11 views19 slides
Global airborne satcom market report by
Global airborne satcom market reportGlobal airborne satcom market report
Global airborne satcom market reportdefencereport78
7 views13 slides
Web Dev Session 1.pptx by
Web Dev Session 1.pptxWeb Dev Session 1.pptx
Web Dev Session 1.pptxVedVekhande
20 views22 slides

Recently uploaded(20)

Créativité dans le design mécanique à l’aide de l’optimisation topologique by LIEGE CREATIVE
Créativité dans le design mécanique à l’aide de l’optimisation topologiqueCréativité dans le design mécanique à l’aide de l’optimisation topologique
Créativité dans le design mécanique à l’aide de l’optimisation topologique
LIEGE CREATIVE8 views
REACTJS.pdf by ArthyR3
REACTJS.pdfREACTJS.pdf
REACTJS.pdf
ArthyR337 views
Unlocking Research Visibility.pdf by KhatirNaima
Unlocking Research Visibility.pdfUnlocking Research Visibility.pdf
Unlocking Research Visibility.pdf
KhatirNaima11 views
Web Dev Session 1.pptx by VedVekhande
Web Dev Session 1.pptxWeb Dev Session 1.pptx
Web Dev Session 1.pptx
VedVekhande20 views
Integrating Sustainable Development Goals (SDGs) in School Education by SheetalTank1
Integrating Sustainable Development Goals (SDGs) in School EducationIntegrating Sustainable Development Goals (SDGs) in School Education
Integrating Sustainable Development Goals (SDGs) in School Education
SheetalTank111 views
Design_Discover_Develop_Campaign.pptx by ShivanshSeth6
Design_Discover_Develop_Campaign.pptxDesign_Discover_Develop_Campaign.pptx
Design_Discover_Develop_Campaign.pptx
ShivanshSeth655 views
Ansari: Practical experiences with an LLM-based Islamic Assistant by M Waleed Kadous
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic Assistant
M Waleed Kadous11 views
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc... by csegroupvn
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
csegroupvn13 views
Design of machine elements-UNIT 3.pptx by gopinathcreddy
Design of machine elements-UNIT 3.pptxDesign of machine elements-UNIT 3.pptx
Design of machine elements-UNIT 3.pptx
gopinathcreddy38 views
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx by lwang78
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
lwang78188 views
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth by Innomantra
BCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for GrowthBCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for Growth
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth
Innomantra 20 views

Featured

Introduction to Data Science by
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceChristy Abraham Joy
82.6K views51 slides
Time Management & Productivity - Best Practices by
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
169.8K views42 slides
The six step guide to practical project management by
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
36.7K views27 slides
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright... by
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
12.7K views21 slides
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present... by
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
55.5K views138 slides
12 Ways to Increase Your Influence at Work by
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
401.7K views64 slides

Featured(20)

Time Management & Productivity - Best Practices by Vit Horky
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky169.8K views
The six step guide to practical project management by MindGenius
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius36.7K views
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright... by RachelPearson36
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson3612.7K views
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present... by Applitools
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools55.5K views
12 Ways to Increase Your Influence at Work by GetSmarter
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter401.7K views
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G... by DevGAMM Conference
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference3.6K views
Barbie - Brand Strategy Presentation by Erica Santiago
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago25.1K views
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well by Saba Software
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software25.3K views
Introduction to C Programming Language by Simplilearn
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
Simplilearn8.5K views
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr... by Palo Alto Software
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
Palo Alto Software88.4K views
9 Tips for a Work-free Vacation by Weekdone.com
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
Weekdone.com7.2K views
How to Map Your Future by SlideShop.com
How to Map Your FutureHow to Map Your Future
How to Map Your Future
SlideShop.com275.1K views
Beyond Pride: Making Digital Marketing & SEO Authentically LGBTQ+ Inclusive -... by AccuraCast
Beyond Pride: Making Digital Marketing & SEO Authentically LGBTQ+ Inclusive -...Beyond Pride: Making Digital Marketing & SEO Authentically LGBTQ+ Inclusive -...
Beyond Pride: Making Digital Marketing & SEO Authentically LGBTQ+ Inclusive -...
AccuraCast3.4K views
Exploring ChatGPT for Effective Teaching and Learning.pptx by Stan Skrabut, Ed.D.
Exploring ChatGPT for Effective Teaching and Learning.pptxExploring ChatGPT for Effective Teaching and Learning.pptx
Exploring ChatGPT for Effective Teaching and Learning.pptx
Stan Skrabut, Ed.D.57.7K views
How to train your robot (with Deep Reinforcement Learning) by Lucas García, PhD
How to train your robot (with Deep Reinforcement Learning)How to train your robot (with Deep Reinforcement Learning)
How to train your robot (with Deep Reinforcement Learning)
Lucas García, PhD42.5K views

18 Оттенков I18n

Editor's Notes

  1. Здравствуйте. Здравствуйте. Здравствуйте. Я – Алексей Кутепов и я люблю python. Работаю над переводом backoffice POS компании Revel . Компания сравнительно недавно, год назад, вышла на мировой рынок. Этот доклад будет про то, как это было. Надеюсь вам пригодится.
  2. Интернационализация. Каждый определит его по-своему. Для этой презентации под интернационализацией будем понимать набор средств и подходов для упрощения локализации. Локализация -- это процесс адаптации продукта для определённой местности. Понятие очень широкое, это не только сам перевод текста (даже на изображениях), но и единицы измерений, форматы времени, чисел, особенности восприятия цветов в разных культурах, налогообложение (у нас это одна из основных проблем). Интернационализация – это процесс облегчающий локализацию. То есть набор средств и подходов. И всё-таки я предпочёл назвать этот доклад «интернационализация», потому что большей частью мы пишем то, что позволяет автоматизировать локализацию.
  3. gettext comes from solaris catgets: The reason for this lies in the third argument of catgets: the unique message ID Neither method is a POSIX standard This all began in July 1994 Patrick D’Cruze I18n of fileutils Jim Meyering, the maintainer, asked Richard Stallman about standards and got glocale description. Jim implemented glocale with feedback from Richard Stollman, Patrick and Mitchum DSouza (catgets-like package mainteiner)
  4. Люди придумали локаль. Локаль – это набор настроек определяющий UI для данного региона, включая и язык. Number format setting Сase conversion settings Date-time format setting String collation setting Currency format setting Paper size setting Keyboard layout
  5. Люди придумали локаль. Локаль – это набор настроек определяющий UI для данного региона, включая и язык. Number format setting Сase conversion settings Date-time format setting String collation setting Currency format setting Paper size setting
  6. Но, локализация это ещё не всё. Изображения (одежда персонажей) Звуковое сопровождение Видеоряд (пролог к игре fallout видеоряд начинается с ядерного взрыва, в локализации для Японии видеоряд начинается в подземелье) Разница восприятия цветов в разных культурах (броские цвета в Корее, Японии и Китае) Расчёт налогов это тоже локализация.
  7. Ка
  8. Форматы лежат в отдельном файле formats.py в формате Transifex, о котором я расскажу дальше.
  9. Взлянем, как происходит процесс I18n на примере меня. Я помечаю строки в коде, нужно ли их переводить или нет. Затем отдаю переводчику в удобном для человека формате. Переводчик возвращает работу в том же формате. Я компилирую это всё в формат удобный для машины. И получаю локализованный продукт. Как видите, картинки остались нелокализованными, потому что gettext это не может, что и не удивительно.
  10. Это работаю я, сначала я помечаю текст, который должен быть переведен. Я нашёл этот dictionary, и ключи помечаю как неподлежащие переводу, а
  11. Это работаю я, сначала я помечаю текст, который должен быть переведен. Я нашёл этот dictionary, и ключи помечаю как неподлежащие переводу, а
  12. Translation memory – перевод слов запоминается, если встречается уже переведенные слова, то они автоматически заменяются переводом. Это экономит очень много сил переводчиков.
  13. Transifex – платный сервер переводов SaaS. Django использует формат Transifex для хранения файла форматов.
  14. Не всегда удаётся внедрить проверенные решения. Поэтому фантазируем.
  15. Полученный PO файл теперь можно скомпилировать в MO файл, удобный для использования нашей системой.
  16. Переводчики хотят контекста.
  17. Удобно составлять строки динамически, особенно в сложных системах. Английский язык позволяет конструировать предложения легче, чем, например, русский. В данном примере кажется за счёт интенсивного контекста все неоднозначности решены. Но перевод затруднён. При таком подходе невозможно изменить порядок слов, который необходим для качественного перевода.