A set of functions for working with GNU gettext translation files, including translation generation tools to go from PO files to cljc.
A set of functions for working with GNU gettext translation files, including translation generation tools to go from PO files to cljc.
(block->translation gettext-block)
(deploy-translations {:keys [src po as-modules?]
:or {src "src" po "i18n" as-modules? false}
:as settings})
Scans for .po files and generates cljc for those translations in your app. At the moment, these must be output to
the package translations
.
The settings map should contain:
:src - The source folder (base) of where to emit the files. Defaults to src
:po - The directory where you po files live. Defaults to i18n
:as-modules? - If true, generates the locales so they can be dynamically loaded. NOTE: You must configure your build to support this as well
by putting each locale in a module with the locale's cljs keyword (e.g. a module :de-AT { :entries #{translations/de-AT}}).
Scans for .po files and generates cljc for those translations in your app. At the moment, these must be output to the package `translations`. The settings map should contain: :src - The source folder (base) of where to emit the files. Defaults to `src` :po - The directory where you po files live. Defaults to `i18n` :as-modules? - If true, generates the locales so they can be dynamically loaded. NOTE: You must configure your build to support this as well by putting each locale in a module with the locale's cljs keyword (e.g. a module :de-AT { :entries #{translations/de-AT}}).
(extract-strings {:keys [js-path po] :or {js-path "i18n/i18n.js" po "i18n"}})
Extract strings from a compiled js file (whitespace optimized) as a PO template. If existing translations exist
then this function will auto-update those (using msgmerge
) as well.
Remember that you must first compile your application (without modules) and with :whitespace
optimization to generate
a single javascript file. The gettext tools know how to extract from Javascript, but not Clojurescript.
Parameters:
:js-path
- The path to your generated javascript (defaults to i18n/i18n.js
from project root)
:po
- The directory where your PO template and PO files should live (defaults to i18n
from project root).
Extract strings from a compiled js file (whitespace optimized) as a PO template. If existing translations exist then this function will auto-update those (using `msgmerge`) as well. Remember that you must first compile your application (*without* modules) and with `:whitespace` optimization to generate a single javascript file. The gettext tools know how to extract from Javascript, but not Clojurescript. Parameters: `:js-path` - The path to your generated javascript (defaults to `i18n/i18n.js` from project root) `:po` - The directory where your PO template and PO files should live (defaults to `i18n` from project root).
(get-blocks resource)
(is-header? entry)
(strip-comments string)
Given a sequence of strings that possibly contain comments of the form # ... <newline>: Return the sequence of strings without those comments.
Given a sequence of strings that possibly contain comments of the form # ... <newline>: Return the sequence of strings without those comments.
(stripquotes s)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close