- Odin 100%
| data |
Update to Podin ver. 0.5.0 compatible with Odin 2026_03 new core.os API.
|
|
| src | Version 0.6.1: improve comments and small code streamlining. | |
| .gitignore | Add tests. | |
| LICENSE.md | Version 0.2.0 | |
| ols.json | Initial, non-working, commit | |
| README.md |
Update to Podin ver. 0.5.0 compatible with Odin 2026_03 new core.os API.
|
|
PODIN
.pot generation utility from Odin sources
Caution: this project is a way for me to familiarise with Odin while realising something relatively small but still potentially useful. Do not take it as anything more serious than that!
Current Podin version:
ver. 0.6.0
Compatibility with Odin versions
This project targets the latest release of Odin and has been tested with Odin version 2026-05.
With Odin version 2026-03, the API for the core.os package was greatly improved and this Podin version follows the new API. To be compatible with Odin versions 2026-02 and older, the Podin version 0.5. should be used instead.
With Odin version 2024-07, the API for the core:text/i18n package changed and this Podin version follows the new API. For Odin versions 2024-06 and older, the Podin version 0.3.0 should be used instead.
Compatibility with Odin versions older than 2024-03 is not guaranteed.
Key Features:
- Generates a
.pottemplate for catalogues of translatable message (à laGNU gettext()) from parameters ofi18n.get()andi18n.get_n()calls. - Scans an entire subdirectory of
.odinsource files recursively. - Generated
.potfiles are compatible with PoEdit and other similar tools and can be managed with them, for translations and other operations. - The
i18npackage can be aliased when imported: for instance in the statementimport i "core:text/i18n",iwill be recognised as an alias ofi18n. - The
i18n.get()andi18n.get_n()calls can be aliased: for instance, after the statementsT_ :: i18n.getandTn :: i18n.get_n"T_(...)" and "Tn(...)" will be recognised as aliases ofi18n.get(...)andi18n.get_n(...)respectively (wherei18nstands for the package name or for its alias, if defined).
Limitations:
- Currently
Podinonly detects calls to thei18n.get()andi18n.get_n()procedure groups in their various (aliased) parameter forms.Podindoes not recognise:- the underlying procedure calls (
get_single_section(),get_by_section()and so on); - calls to
get_by_slot()group and its components (get_by_slot_single_section()andget_by_slot_by_section());
- the underlying procedure calls (
- Currently it does not update existing catalogue templates, but only generate new ones.
- Currently
Podinonly generates.pottemplates from directories of Odin source files; generation of.pofiles is currently disabled until a better implementation of locale management will be in place (WIP!). - Working under Linux is actively tested, testing under Windows is occasional and testing other OSes relies on the kindness of other users!
Installing
The package is self-contained and has no external dependencies.
- Copy the whole project by any way available (from
git clone-ing this repository to downloading a ZIP — from the 'tree-dot' menu at the top-right of the file list — to manual file copying...). - Compile it: the resulting executable can be moved anywhere and executed from anywhere.
Running
To collect the translatable messages from .odin files in directory my_dir run:
podin path/to/my_dir
This results in a messages.pot file in the current directory.
Recognised call
The current Podin version recognises the following calls and will export the literal strings contained in them
(the documentation of the i18n package provided with Odin is here):
Immutable message calls:
i18n.get("Text")i18n.get("Text", catalogue)i18n.get("Context", "Text")i18n.get("Context", "Text", catalogue)
Quantifiable message calls:
i18n.get_n("Text", quantity)i18n.get_n("Text", quantity, catalogue)i18n.get_n("Context", "Text", quantity)i18n.get_n("Context", "Text", quantity, catalogue)
Source marking
For the calls to the i18n.get() procedures (and their aliases) to be recognised, they must have literal strings, rather then identifiers; for instance, the strings in the following statements will all be collected in the output .pot:
fmt.println(i18n.get("%d occurrences found", occur), occur) // `get()` call contains literal string(s)
msg = i18n.get("Operation succeeded") if success else i18n.get("Operation failed") // each call contains just the needed parameters
fmt.println(msg)
while the strings in the following statements will not be collected:
msg = "Operation succeeded" if success else "Operation failed"
fmt.println(i18n.get(msg)) // no literal string in the `get()` call
Also, the calls must contain the needed parameters directly, without expressions: for instance, this will not be recognised:
msg = i18n.get("Operation succeeded" if success else "Operation failed") // `get()` contains expressions rather than simple parameters
fmt.println(msg)
In addition to the strings in the calls to i18n.get(), i18n.get_n() (and their alias), the sources may contain comments starting with the string "// TRANSLATORS" (for single line comments) or "/* TRANSLATORS" (for multi-line comments); the contents of these comments is collected and inserted in the relevant .pot entry and it will be recognised by PoEdit and other .po/.pot tools and presented to users during translations.
Note 1: The comment beginning should be exactly as shown:
- Ony one space between the comment mark and the text
- The exact text "TRANSLATORS" in upper case after that space.
Note 2: Between such a comment and the i18n.get() / i18n.get_n() call it refers to, there should **not be any intervening other comment.
Contributing
Pull requests and bug or issue reports are very welcome, as well as suggestions about code style improvements!