Mix.MishkaCmsCore.GettextTemplates (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Writes messages marked outside the core into the core's .pot files, for mix mishka_cms_core.gettext.gervaz and mix mishka_cms_core.gettext.extensions.

A source is a project and its templates by file name ("default.pot"), with references relative to that project. merge/3 writes them into the core's priv/gettext:

  • a message with a reference into the core is left as it is, since mix gettext.extract writes its references;
  • any other message the source has gets the source's references, relative to the core, beside those of the other sources, and keeps its flags and comments while another source references it too; one no other source references is the source's own, and one the core's template lacks is added at its end;
  • a reference into the source that the source no longer has is removed, and with it a message no source references any longer.

The core's :excluded_refs_from_purging matches every reference outside the core, so the next mix gettext.extract keeps what is written here, and mix gettext.extract --check-up-to-date still passes. A template that changes is written and named on the shell.

Summary

Functions

Writes the templates of the project at source into the .pot files of the core at core.

Functions

merge(core, source, templates)

@spec merge(Path.t(), Path.t(), %{required(String.t()) => Expo.Messages.t()}) :: :ok

Writes the templates of the project at source into the .pot files of the core at core.

templates maps a template's file name to its Expo.Messages, with references relative to source. A reference outside source is left out. Every template of the core is visited, so the references of a domain the source no longer marks are removed too.