View Source Expo

hex.pm badge Documentation badge .github/workflows/branch_main.yml Coverage Status

Low-level GNU gettext file handling (for .po, .pot, and .mo files), including writing and parsing.

See the documentation.

For a full Gettext integration, see the Gettext library.

Usage

Expo can parse PO, POT, and MO files from GNU gettext:

Expo.PO.parse_file!("priv/gettext/default.pot")
#=> %Expo.Messages{...}

It can also write well-formed PO, POT, and MO files:

"priv/gettext/default.pot"
|> Expo.PO.parse_file!()
|> Expo.PO.compose()
|> then(fn content -> File.write!("priv/gettext/copy.pot", content) end)

This library can also parse Plural-Form headers in PO or POT files, and ships with a built-in list of languages and their plural forms. You can find which plural form to use for a given amount by using Expo.PluralForms.index/2:

{:ok, plural_form} = Expo.PluralForms.plural_form("de")

Expo.PluralForms.index(plural_form, 1)
#=> 0
Expo.PluralForms.index(plural_form, 213)
#=> 1

License

Copyright 2015 Plataformatec Copyright 2020 Dashbit 2022 JOSHMARTIN GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.