1
1
Fork
You've already forked podin
2
An Odin package to extract translatable strings from Odin sources into a .POT file.
  • Odin 100%
2026年06月07日 09:03:04 +02:00
data Update to Podin ver. 0.5.0 compatible with Odin 2026_03 new core.os API. 2026年05月24日 09:39:05 +02:00
src Version 0.6.1: improve comments and small code streamlining. 2026年06月07日 09:03:04 +02:00
.gitignore Add tests. 2024年05月31日 18:29:40 +02:00
LICENSE.md Version 0.2.0 2024年07月02日 10:33:47 +02:00
ols.json Initial, non-working, commit 2024年05月13日 17:52:57 +02:00
README.md Update to Podin ver. 0.5.0 compatible with Odin 2026_03 new core.os API. 2026年05月24日 09:39:05 +02:00

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 .pot template for catalogues of translatable message (à la GNU gettext()) from parameters of i18n.get() and i18n.get_n() calls.
  • Scans an entire subdirectory of .odin source files recursively.
  • Generated .pot files are compatible with PoEdit and other similar tools and can be managed with them, for translations and other operations.
  • The i18n package can be aliased when imported: for instance in the statement import i "core:text/i18n", i will be recognised as an alias of i18n.
  • The i18n.get() and i18n.get_n() calls can be aliased: for instance, after the statements T_ :: i18n.get and Tn :: i18n.get_n "T_(...)" and "Tn(...)" will be recognised as aliases of i18n.get(...) and i18n.get_n(...) respectively (where i18n stands for the package name or for its alias, if defined).

Limitations:

  • Currently Podin only detects calls to the i18n.get() and i18n.get_n() procedure groups in their various (aliased) parameter forms. Podin does 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() and get_by_slot_by_section());
  • Currently it does not update existing catalogue templates, but only generate new ones.
  • Currently Podin only generates .pot templates from directories of Odin source files; generation of .po files 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.

  1. 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...).
  2. 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:

  1. Ony one space between the comment mark and the text
  2. 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!