From deee4acd79aad8a57fd9ae5ed49bf348db4a6ea2 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 29 Sep 2025 11:49:35 +0200 Subject: [PATCH] feat: param line size --- .../LC_MESSAGES/rougail_output_formatter.po | 37 ++++++++++++++++++ locale/rougail_output_formatter.pot | 37 ++++++++++++++++++ src/rougail/output_formatter/__init__.py | 6 +-- src/rougail/output_formatter/config.py | 24 +++++++----- src/rougail/output_formatter/i18n.py | 27 +++++++++++++ .../LC_MESSAGES/rougail_output_formatter.mo | Bin 0 -> 735 bytes 6 files changed, 118 insertions(+), 13 deletions(-) create mode 100644 locale/fr/LC_MESSAGES/rougail_output_formatter.po create mode 100644 locale/rougail_output_formatter.pot create mode 100644 src/rougail/output_formatter/i18n.py create mode 100644 src/rougail/output_formatter/locale/fr/LC_MESSAGES/rougail_output_formatter.mo diff --git a/locale/fr/LC_MESSAGES/rougail_output_formatter.po b/locale/fr/LC_MESSAGES/rougail_output_formatter.po new file mode 100644 index 0000000..edc5e50 --- /dev/null +++ b/locale/fr/LC_MESSAGES/rougail_output_formatter.po @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2025-09-29 11:38+0200\n" +"PO-Revision-Date: 2025-09-29 11:46+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" +"X-Generator: Poedit 3.7\n" + +#: src/rougail/output_formatter/__init__.py:105 +msgid "the \"step.output\" is not set to \"{0}\"" +msgstr "\"step.output\" n'est pas défini pour \"{0}\"" + +#: src/rougail/output_formatter/__init__.py:155 +msgid "only one file is allowed" +msgstr "seulement un fichier est autorisé" + +#: src/rougail/output_formatter/__init__.py:158 +msgid "only a file is allowed" +msgstr "seulement un fichier est autorisé" + +#: src/rougail/output_formatter/config.py:59 +msgid "Configuration for rougail-ouput-formatter" +msgstr "Configuration pour rougail-ouput-formatter" + +#: src/rougail/output_formatter/config.py:61 +msgid "Line size" +msgstr "Taille des lignes" diff --git a/locale/rougail_output_formatter.pot b/locale/rougail_output_formatter.pot new file mode 100644 index 0000000..c4f6f76 --- /dev/null +++ b/locale/rougail_output_formatter.pot @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2025-09-29 11:47+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" + + +#: src/rougail/output_formatter/__init__.py:105 +msgid "the \"step.output\" is not set to \"{0}\"" +msgstr "" + +#: src/rougail/output_formatter/__init__.py:155 +msgid "only one file is allowed" +msgstr "" + +#: src/rougail/output_formatter/__init__.py:158 +msgid "only a file is allowed" +msgstr "" + +#: src/rougail/output_formatter/config.py:59 +msgid "Configuration for rougail-ouput-formatter" +msgstr "" + +#: src/rougail/output_formatter/config.py:61 +msgid "Line size" +msgstr "" + diff --git a/src/rougail/output_formatter/__init__.py b/src/rougail/output_formatter/__init__.py index 8a286d5..b0210de 100644 --- a/src/rougail/output_formatter/__init__.py +++ b/src/rougail/output_formatter/__init__.py @@ -57,13 +57,10 @@ from rougail.tiramisu import normalize_family, RENAME_TYPE from rougail.utils import undefined from .upgrade import RougailUpgrade +from .i18n import _ from .__version__ import __version__ -def _(text): - return text - - # XXX explicit null def represent_none(self, data): return self.represent_scalar("tag:yaml.org,2002:null", "null") @@ -119,6 +116,7 @@ class RougailOutputFormatter: self.attributes = {} self.yaml = YAML() + self.yaml.width = self.rougailconfig["formatter.line_width"] self.conv_yaml = YAML() def run(self): diff --git a/src/rougail/output_formatter/config.py b/src/rougail/output_formatter/config.py index ab58844..bdeb356 100644 --- a/src/rougail/output_formatter/config.py +++ b/src/rougail/output_formatter/config.py @@ -17,28 +17,29 @@ along with this program. If not, see . """ from pathlib import Path +from .i18n import _ def get_rougail_config( *, backward_compatibility=True, ) -> dict: - options = """ + options = f""" load_unexist_redefine: redefine: true type: boolean default: jinja: >- - {% if step.output is not propertyerror and step.output == 'formatter' %} + {{% if step.output is not propertyerror and step.output == 'formatter' %}} true - {% else %} + {{% else %}} false - {% endif %} + {{% endif %}} hidden: jinja: >- - {% if step.output is not propertyerror and step.output == 'formatter' %} + {{% if step.output is not propertyerror and step.output == 'formatter' %}} load_unexist_redefine is always true with 'formatter' output - {% endif %} + {{% endif %}} cli: @@ -48,11 +49,16 @@ cli: type: boolean default: jinja: >- - {% if step.output is not propertyerror and step.output == 'formatter' %} + {{% if step.output is not propertyerror and step.output == 'formatter' %}} false - {% else %} + {{% else %}} true - {% endif %} + {{% endif %}} + +formatter: + description: {_('Configuration for rougail-ouput-formatter')} + + line_width: 120 # {_('Line size')} """ return { "name": "formatter", diff --git a/src/rougail/output_formatter/i18n.py b/src/rougail/output_formatter/i18n.py new file mode 100644 index 0000000..3b8fe6f --- /dev/null +++ b/src/rougail/output_formatter/i18n.py @@ -0,0 +1,27 @@ +"""Internationalisation utilities +Silique (https://www.silique.fr) +Copyright (C) 2025 + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by the +Free Software Foundation, either version 3 of the License, or (at your +option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +""" + +from gettext import translation +from pathlib import Path + +t = translation( + "rougail_output_formatter", str(Path(__file__).parent / "locale"), fallback=True +) + +_ = t.gettext + diff --git a/src/rougail/output_formatter/locale/fr/LC_MESSAGES/rougail_output_formatter.mo b/src/rougail/output_formatter/locale/fr/LC_MESSAGES/rougail_output_formatter.mo new file mode 100644 index 0000000000000000000000000000000000000000..67ad2f42631b9c3022cf89a436df83b166806290 GIT binary patch literal 735 zcma)(&uSDw5XMK1f+HUEARasv10pKD&TNb(BVN=ffekLQiU%+4PR(qG+3umcMl=3- z2oJu4d-o0U2%hyRyb6A^S%?M%3x564)zwu+)sKs7pCi~Aa0QIOIq(7W_61xA3vd>E z1DC*ea2fmrSHbxcQS=MC4!r@*PDarM=qqRfwJZGu?ccvb5xTTfIQ#m&!M(J#m7ZQ{ z^w8PTRIS%yoTbuv@~*A4sg-M+RunvQEy6w;8Os#RJC2;KJJM8|n#lyxb?x4Aap-mk zI{qLtrX&bA1J??YCjBq#gaQkRqvU=1F^R_B?eSF9PN80~4`?T+c>Gj7<2R