├── tests ├── __init__.py ├── test_loaders │ ├── __init__.py │ ├── test_babel_loader.py │ ├── test_json_loader.py │ ├── conftest.py │ └── test_common.py ├── translations │ └── babel │ │ ├── de_DE │ │ └── LC_MESSAGES │ │ │ ├── messages.mo │ │ │ └── messages.po │ │ ├── en_US │ │ └── LC_MESSAGES │ │ │ ├── messages.mo │ │ │ └── messages.po │ │ └── es_AR │ │ └── LC_MESSAGES │ │ ├── messages.mo │ │ └── messages.po ├── conftest.py ├── test_pydantic_messages.py └── test_main.py ├── docs ├── en │ ├── data │ │ └── .gitignore │ ├── docs │ │ ├── img │ │ │ ├── favicon.png │ │ │ ├── icon-white.png │ │ │ ├── logo-white.png │ │ │ └── logo-white.svg │ │ ├── css │ │ │ ├── custom.css │ │ │ └── termynal.css │ │ ├── help-pydantic-i18n.md │ │ ├── js │ │ │ ├── custom.js │ │ │ └── termynal.js │ │ ├── index.md │ │ ├── contributing.md │ │ └── release-notes.md │ ├── overrides │ │ └── main.html │ └── mkdocs.yml └── missing-translation.md ├── pydantic_i18n ├── py.typed ├── __init__.py ├── loaders.py └── main.py ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature-request.md │ └── bug_report.md ├── actions │ └── comment-docs-preview-in-pr │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── action.yml │ │ └── app │ │ └── main.py ├── dependabot.yml └── workflows │ ├── new_contributor_pr.yml │ ├── latest-changes.yml │ ├── publish.yml │ ├── test.yml │ ├── preview-docs.yml │ └── build-docs.yml ├── scripts ├── publish.sh ├── docs-live.sh ├── build-docs.sh ├── test-cov-html.sh ├── clean.sh ├── zip-docs.sh ├── test.sh ├── format-imports.sh ├── lint.sh ├── format.sh └── docs.py ├── docs_src ├── pydantic_v1 │ ├── own-loader │ │ ├── translations │ │ │ ├── en_US.csv │ │ │ └── de_DE.csv │ │ └── tutorial001.py │ ├── json-loader │ │ ├── translations │ │ │ ├── en_US.json │ │ │ └── de_DE.json │ │ └── tutorial001.py │ ├── babel-loader │ │ ├── translations │ │ │ ├── de_DE │ │ │ │ └── LC_MESSAGES │ │ │ │ │ ├── messages.mo │ │ │ │ │ └── messages.po │ │ │ └── en_US │ │ │ │ └── LC_MESSAGES │ │ │ │ ├── messages.mo │ │ │ │ └── messages.po │ │ └── tutorial001.py │ ├── fastapi-usage │ │ ├── main.py │ │ └── tr.py │ ├── pydantic-messages │ │ ├── tutorial001.py │ │ └── tutorial002.py │ ├── dict-loader │ │ └── tutorial001.py │ └── placeholder │ │ └── tutorial001.py └── pydantic_v2 │ ├── own-loader │ ├── translations │ │ ├── en_US.csv │ │ └── de_DE.csv │ └── tutorial001.py │ ├── json-loader │ ├── translations │ │ ├── en_US.json │ │ └── de_DE.json │ └── tutorial001.py │ ├── fastapi-usage │ ├── main.py │ └── tr.py │ ├── pydantic-messages │ ├── tutorial001.py │ └── tutorial002.py │ ├── babel-loader │ ├── translations │ │ ├── de_DE │ │ │ └── LC_MESSAGES │ │ │ │ ├── messages.mo │ │ │ │ └── messages.po │ │ └── en_US │ │ │ └── LC_MESSAGES │ │ │ ├── messages.mo │ │ │ └── messages.po │ └── tutorial001.py │ ├── dict-loader │ └── tutorial001.py │ └── placeholder │ └── tutorial001.py ├── .editorconfig ├── setup.cfg ├── mypy.ini ├── .coveragerc ├── LICENSE ├── pyproject.toml ├── .gitignore └── README.md /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/en/data/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pydantic_i18n/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test_loaders/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /scripts/publish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | flit publish 6 | -------------------------------------------------------------------------------- /docs_src/pydantic_v1/own-loader/translations/en_US.csv: -------------------------------------------------------------------------------- 1 | field required,field required 2 | -------------------------------------------------------------------------------- /docs_src/pydantic_v2/own-loader/translations/en_US.csv: -------------------------------------------------------------------------------- 1 | Field required,field required 2 | -------------------------------------------------------------------------------- /docs_src/pydantic_v1/own-loader/translations/de_DE.csv: -------------------------------------------------------------------------------- 1 | field required,Feld erforderlich 2 | -------------------------------------------------------------------------------- /docs_src/pydantic_v2/own-loader/translations/de_DE.csv: -------------------------------------------------------------------------------- 1 | Field required,Feld erforderlich 2 | -------------------------------------------------------------------------------- /scripts/docs-live.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | mkdocs serve --dev-addr 0.0.0.0:8008 6 | -------------------------------------------------------------------------------- /docs_src/pydantic_v1/json-loader/translations/en_US.json: -------------------------------------------------------------------------------- 1 | { 2 | "field required": "field required" 3 | } 4 | -------------------------------------------------------------------------------- /docs_src/pydantic_v2/json-loader/translations/en_US.json: -------------------------------------------------------------------------------- 1 | { 2 | "Field required": "field required" 3 | } 4 | -------------------------------------------------------------------------------- /docs/en/docs/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boardpack/pydantic-i18n/HEAD/docs/en/docs/img/favicon.png -------------------------------------------------------------------------------- /docs_src/pydantic_v1/json-loader/translations/de_DE.json: -------------------------------------------------------------------------------- 1 | { 2 | "field required": "Feld erforderlich" 3 | } 4 | -------------------------------------------------------------------------------- /docs_src/pydantic_v2/json-loader/translations/de_DE.json: -------------------------------------------------------------------------------- 1 | { 2 | "Field required": "Feld erforderlich" 3 | } 4 | -------------------------------------------------------------------------------- /scripts/build-docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -x 5 | 6 | python ./scripts/docs.py build-all 7 | -------------------------------------------------------------------------------- /docs/en/docs/img/icon-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boardpack/pydantic-i18n/HEAD/docs/en/docs/img/icon-white.png -------------------------------------------------------------------------------- /docs/en/docs/img/logo-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boardpack/pydantic-i18n/HEAD/docs/en/docs/img/logo-white.png -------------------------------------------------------------------------------- /scripts/test-cov-html.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -x 5 | 6 | bash scripts/test.sh --cov-report=html ${@} 7 | -------------------------------------------------------------------------------- /scripts/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | if [ -d 'dist' ] ; then 4 | rm -r dist 5 | fi 6 | if [ -d 'site' ] ; then 7 | rm -r site 8 | fi 9 | -------------------------------------------------------------------------------- /tests/translations/babel/de_DE/LC_MESSAGES/messages.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boardpack/pydantic-i18n/HEAD/tests/translations/babel/de_DE/LC_MESSAGES/messages.mo -------------------------------------------------------------------------------- /tests/translations/babel/en_US/LC_MESSAGES/messages.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boardpack/pydantic-i18n/HEAD/tests/translations/babel/en_US/LC_MESSAGES/messages.mo -------------------------------------------------------------------------------- /tests/translations/babel/es_AR/LC_MESSAGES/messages.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boardpack/pydantic-i18n/HEAD/tests/translations/babel/es_AR/LC_MESSAGES/messages.mo -------------------------------------------------------------------------------- /scripts/zip-docs.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | set -x 4 | set -e 5 | 6 | if [ -f docs.zip ]; then 7 | rm -rf docs.zip 8 | fi 9 | zip -r docs.zip ./site 10 | -------------------------------------------------------------------------------- /.github/actions/comment-docs-preview-in-pr/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.7 2 | 3 | RUN pip install httpx "pydantic==1.5.1" pygithub 4 | 5 | COPY ./app /app 6 | 7 | CMD ["python", "/app/main.py"] 8 | -------------------------------------------------------------------------------- /scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -x 5 | 6 | bash ./scripts/lint.sh 7 | pytest --cov=pydantic_i18n --cov=tests --cov-report=term-missing --cov-report=xml tests ${@} 8 | -------------------------------------------------------------------------------- /docs_src/pydantic_v1/babel-loader/translations/de_DE/LC_MESSAGES/messages.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boardpack/pydantic-i18n/HEAD/docs_src/pydantic_v1/babel-loader/translations/de_DE/LC_MESSAGES/messages.mo -------------------------------------------------------------------------------- /docs_src/pydantic_v1/babel-loader/translations/en_US/LC_MESSAGES/messages.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boardpack/pydantic-i18n/HEAD/docs_src/pydantic_v1/babel-loader/translations/en_US/LC_MESSAGES/messages.mo -------------------------------------------------------------------------------- /scripts/format-imports.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | set -x 3 | 4 | # Sort imports one per line, so autoflake can remove unused imports 5 | isort pydantic_i18n tests scripts --force-single-line-imports 6 | sh ./scripts/format.sh 7 | -------------------------------------------------------------------------------- /scripts/lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -x 5 | 6 | mypy pydantic_i18n 7 | flake8 pydantic_i18n tests 8 | black pydantic_i18n tests --check 9 | isort pydantic_i18n tests scripts --check-only 10 | -------------------------------------------------------------------------------- /docs/missing-translation.md: -------------------------------------------------------------------------------- 1 | !!! warning 2 | The current page still doesn't have a translation for this language. 3 | 4 | But you can help translating it: [Contributing](https://pydantic-i18n.boardpack.org/contributing/){.internal-link target=_blank}. 5 | -------------------------------------------------------------------------------- /tests/test_loaders/test_babel_loader.py: -------------------------------------------------------------------------------- 1 | from pydantic_i18n import BabelLoader 2 | 3 | 4 | def test_init(babel_translations_directory: str): 5 | babel_loader = BabelLoader(babel_translations_directory) 6 | assert len(babel_loader.translations) >= 2 7 | -------------------------------------------------------------------------------- /scripts/format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | set -x 3 | 4 | autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place pydantic_i18n tests scripts --exclude=__init__.py 5 | black pydantic_i18n tests scripts 6 | isort pydantic_i18n tests scripts 7 | -------------------------------------------------------------------------------- /docs/en/overrides/main.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block site_nav %} 4 |
11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /docs/en/docs/css/custom.css: -------------------------------------------------------------------------------- 1 | 2 | a.external-link::after { 3 | /* \00A0 is a non-breaking space 4 | to make the mark be on the same line as the link 5 | */ 6 | content: "\00A0[↪]"; 7 | } 8 | 9 | a.internal-link::after { 10 | /* \00A0 is a non-breaking space 11 | to make the mark be on the same line as the link 12 | */ 13 | content: "\00A0↪"; 14 | } 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import pytest 4 | 5 | from pydantic_i18n import BabelLoader 6 | 7 | 8 | @pytest.fixture 9 | def babel_translations_directory() -> str: 10 | return os.path.abspath("./tests/translations/babel") 11 | 12 | 13 | @pytest.fixture 14 | def babel_loader(babel_translations_directory: str) -> BabelLoader: 15 | return BabelLoader(babel_translations_directory) 16 | -------------------------------------------------------------------------------- /.github/actions/comment-docs-preview-in-pr/README.md: -------------------------------------------------------------------------------- 1 | # Comment docs preview in PR 2 | 3 | This action was used from the [FastAPI](https://github.com/tiangolo/fastapi) project, original one can be found [here](https://github.com/tiangolo/fastapi/tree/master/.github/actions/comment-docs-preview-in-pr). Special thanks to [Sebastián Ramírez](https://github.com/tiangolo). 4 | 5 | ## License 6 | 7 | This project is licensed under the terms of the MIT license. 8 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = E203, E266, E501, W503 3 | max-line-length = 88 4 | max-complexity = 18 5 | select = B,C,E,F,W,T4 6 | exclude = docs, __init__.py 7 | 8 | [isort] 9 | multi_line_output=3 10 | include_trailing_comma=True 11 | force_grid_wrap=0 12 | use_parentheses=True 13 | line_length=88 14 | 15 | [mypy] 16 | files=pydantic_i18n,tests 17 | ignore_missing_imports=true 18 | 19 | [aliases] 20 | test = pytest 21 | 22 | [tool:pytest] 23 | testpaths=tests/ 24 | -------------------------------------------------------------------------------- /mypy.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | 3 | # --strict 4 | disallow_any_generics = True 5 | disallow_subclassing_any = True 6 | disallow_untyped_calls = True 7 | disallow_untyped_defs = True 8 | disallow_incomplete_defs = True 9 | check_untyped_defs = True 10 | disallow_untyped_decorators = True 11 | no_implicit_optional = True 12 | warn_redundant_casts = True 13 | warn_unused_ignores = True 14 | warn_return_any = True 15 | implicit_reexport = False 16 | strict_equality = True 17 | # --strict end 18 | -------------------------------------------------------------------------------- /pydantic_i18n/__init__.py: -------------------------------------------------------------------------------- 1 | """pydantic-i18n is an extension to support an i18n for the pydantic error messages.""" 2 | 3 | __author__ = """Roman Sadzhenytsia""" 4 | __email__ = "urchin.dukkee@gmail.com" 5 | __version__ = "0.4.5" 6 | 7 | from .loaders import BabelLoader, BaseLoader, DictLoader, JsonLoader 8 | from .main import PydanticI18n 9 | 10 | __all__ = ( 11 | "PydanticI18n", 12 | "BaseLoader", 13 | "BabelLoader", 14 | "DictLoader", 15 | "JsonLoader", 16 | ) 17 | -------------------------------------------------------------------------------- /.github/actions/comment-docs-preview-in-pr/action.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Comment Docs Preview in PR 3 | description: Comment with the docs URL preview in the PR 4 | author: Sebastián Ramírez