Skip to content

Commit

Permalink
feat: add locale data, i18n support
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jul 15, 2023
1 parent 1a5e6a5 commit 6ec547d
Show file tree
Hide file tree
Showing 18 changed files with 626 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ docs/_build
node_modules/
npm-debug.log*

*.mo
src/shibuya/theme/shibuya/static/shibuya.*
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ recursive-include src/shibuya *.js
recursive-include src/shibuya *.css
recursive-include src/shibuya *.html
recursive-include src/shibuya *.conf
recursive-include src/shibuya *.mo
prune build
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@ build-icons:

build-static:
cd static && npm run build

babel-extract:
pybabel extract -F babel.cfg src/shibuya/theme -o src/shibuya/locale/sphinx.pot

lang=zh

babel-init:
pybabel init -D sphinx -i src/shibuya/locale/sphinx.pot -d src/shibuya/locale -l ${lang}

babel-update:
pybabel update -D sphinx -i src/shibuya/locale/sphinx.pot -d src/shibuya/locale -l ${lang}

babel-compile:
pybabel compile -D sphinx -d src/shibuya/locale
4 changes: 4 additions & 0 deletions babel.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[jinja2: **/shibuya/*/**.html]
encoding = utf-8
ignore_tags = script,style
include_attrs = alt title summary placeholder, aria-label
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ sphinx-design==0.4.1
jupyter-sphinx==0.4.0
sphinx-togglebutton==0.3.2
nbsphinx==0.9.2
Babel
4 changes: 3 additions & 1 deletion src/shibuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

shibuya_version = __version__

THEME_PATH = (Path(__file__).parent / "theme" / "shibuya").resolve()
ROOT_PATH = Path(__file__).parent
THEME_PATH = (ROOT_PATH / "theme" / "shibuya").resolve()


def _add_version(name: str):
Expand Down Expand Up @@ -76,6 +77,7 @@ def setup(app: Sphinx):
app.add_post_transform(WrapperPostTransform)
app.connect("builder-inited", _initialize_builder)
app.connect("html-page-context", _html_page_context)
app.add_message_catalog("sphinx", ROOT_PATH / "locale")
return {
"parallel_read_safe": True,
"parallel_write_safe": True,
Expand Down
60 changes: 60 additions & 0 deletions src/shibuya/locale/de/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# German translations for PROJECT.
# Copyright (C) 2023 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-07-15 18:32+0900\n"
"PO-Revision-Date: 2023-07-15 18:41+0900\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: de\n"
"Language-Team: de <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"

#: src/shibuya/theme/shibuya/components/nav-languages.html:4
msgid "Translations"
msgstr "Übersetzungen"

#: src/shibuya/theme/shibuya/components/nav-versions.html:3
#: src/shibuya/theme/shibuya/components/nav-versions.html:4
msgid "Versions"
msgstr "Versionen"

#: src/shibuya/theme/shibuya/components/navigation.html:7
msgid "Previous"
msgstr "Zurück"

#: src/shibuya/theme/shibuya/components/navigation.html:9
msgid "Home"
msgstr "Startseite"

#: src/shibuya/theme/shibuya/components/navigation.html:21
msgid "Next"
msgstr "Weiter"

#: src/shibuya/theme/shibuya/components/searchbox.html:2
msgid "Search"
msgstr "Suche"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to dark mode"
msgstr "In den Dunkelmodus wechseln"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to light mode"
msgstr "In den Hellmodus wechseln"

#: src/shibuya/theme/shibuya/sidebars/edit-this-page.html:7
msgid "Edit this page"
msgstr "Diese Seite bearbeiten"

#: src/shibuya/theme/shibuya/sidebars/localtoc.html:3
msgid "On this page"
msgstr "Auf dieser Seite"
60 changes: 60 additions & 0 deletions src/shibuya/locale/es/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Spanish translations for PROJECT.
# Copyright (C) 2023 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-07-15 18:32+0900\n"
"PO-Revision-Date: 2023-07-15 18:34+0900\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: es\n"
"Language-Team: es <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"

#: src/shibuya/theme/shibuya/components/nav-languages.html:4
msgid "Translations"
msgstr "Traducciones"

#: src/shibuya/theme/shibuya/components/nav-versions.html:3
#: src/shibuya/theme/shibuya/components/nav-versions.html:4
msgid "Versions"
msgstr "Versiones"

#: src/shibuya/theme/shibuya/components/navigation.html:7
msgid "Previous"
msgstr "Anterior"

#: src/shibuya/theme/shibuya/components/navigation.html:9
msgid "Home"
msgstr "Inicio"

#: src/shibuya/theme/shibuya/components/navigation.html:21
msgid "Next"
msgstr "Siguiente"

#: src/shibuya/theme/shibuya/components/searchbox.html:2
msgid "Search"
msgstr "Buscar"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to dark mode"
msgstr "Cambiar a modo oscuro"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to light mode"
msgstr "Cambiar a modo claro"

#: src/shibuya/theme/shibuya/sidebars/edit-this-page.html:7
msgid "Edit this page"
msgstr "Editar esta página"

#: src/shibuya/theme/shibuya/sidebars/localtoc.html:3
msgid "On this page"
msgstr "En esta página"
60 changes: 60 additions & 0 deletions src/shibuya/locale/fr/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# French translations for PROJECT.
# Copyright (C) 2023 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-07-15 18:32+0900\n"
"PO-Revision-Date: 2023-07-15 18:34+0900\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n"
"Language-Team: fr <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"

#: src/shibuya/theme/shibuya/components/nav-languages.html:4
msgid "Translations"
msgstr "Traductions"

#: src/shibuya/theme/shibuya/components/nav-versions.html:3
#: src/shibuya/theme/shibuya/components/nav-versions.html:4
msgid "Versions"
msgstr "Versions"

#: src/shibuya/theme/shibuya/components/navigation.html:7
msgid "Previous"
msgstr "Précédent"

#: src/shibuya/theme/shibuya/components/navigation.html:9
msgid "Home"
msgstr "Accueil"

#: src/shibuya/theme/shibuya/components/navigation.html:21
msgid "Next"
msgstr "Suivant"

#: src/shibuya/theme/shibuya/components/searchbox.html:2
msgid "Search"
msgstr "Rechercher"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to dark mode"
msgstr "Passer en mode sombre"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to light mode"
msgstr "Passer en mode clair"

#: src/shibuya/theme/shibuya/sidebars/edit-this-page.html:7
msgid "Edit this page"
msgstr "Modifier cette page"

#: src/shibuya/theme/shibuya/sidebars/localtoc.html:3
msgid "On this page"
msgstr "Sur cette page"
60 changes: 60 additions & 0 deletions src/shibuya/locale/ja/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Japanese translations for PROJECT.
# Copyright (C) 2023 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-07-15 18:32+0900\n"
"PO-Revision-Date: 2023-07-15 18:33+0900\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ja\n"
"Language-Team: ja <[email protected]>\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"

#: src/shibuya/theme/shibuya/components/nav-languages.html:4
msgid "Translations"
msgstr "翻訳"

#: src/shibuya/theme/shibuya/components/nav-versions.html:3
#: src/shibuya/theme/shibuya/components/nav-versions.html:4
msgid "Versions"
msgstr "バージョン"

#: src/shibuya/theme/shibuya/components/navigation.html:7
msgid "Previous"
msgstr "前へ"

#: src/shibuya/theme/shibuya/components/navigation.html:9
msgid "Home"
msgstr "ホーム"

#: src/shibuya/theme/shibuya/components/navigation.html:21
msgid "Next"
msgstr "次へ"

#: src/shibuya/theme/shibuya/components/searchbox.html:2
msgid "Search"
msgstr "検索"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to dark mode"
msgstr "ダークモードに切り替える"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to light mode"
msgstr "ライトモードに切り替える"

#: src/shibuya/theme/shibuya/sidebars/edit-this-page.html:7
msgid "Edit this page"
msgstr "このページを編集"

#: src/shibuya/theme/shibuya/sidebars/localtoc.html:3
msgid "On this page"
msgstr "このページについて"
60 changes: 60 additions & 0 deletions src/shibuya/locale/ko/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Korean translations for PROJECT.
# Copyright (C) 2023 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-07-15 18:32+0900\n"
"PO-Revision-Date: 2023-07-15 18:39+0900\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ko\n"
"Language-Team: ko <[email protected]>\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"

#: src/shibuya/theme/shibuya/components/nav-languages.html:4
msgid "Translations"
msgstr "번역"

#: src/shibuya/theme/shibuya/components/nav-versions.html:3
#: src/shibuya/theme/shibuya/components/nav-versions.html:4
msgid "Versions"
msgstr "버전"

#: src/shibuya/theme/shibuya/components/navigation.html:7
msgid "Previous"
msgstr "이전"

#: src/shibuya/theme/shibuya/components/navigation.html:9
msgid "Home"
msgstr "홈"

#: src/shibuya/theme/shibuya/components/navigation.html:21
msgid "Next"
msgstr "다음"

#: src/shibuya/theme/shibuya/components/searchbox.html:2
msgid "Search"
msgstr "검색"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to dark mode"
msgstr "다크 모드로 전환"

#: src/shibuya/theme/shibuya/components/site-head.html:44
msgid "Switch to light mode"
msgstr "라이트 모드로 전환"

#: src/shibuya/theme/shibuya/sidebars/edit-this-page.html:7
msgid "Edit this page"
msgstr "이 페이지 편집"

#: src/shibuya/theme/shibuya/sidebars/localtoc.html:3
msgid "On this page"
msgstr "이 페이지에서"
Loading

0 comments on commit 6ec547d

Please sign in to comment.