i18n

package module
v0.0.0-...-47e047f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2025 License: MIT Imports: 4 Imported by: 2

README

Welcome to go-i18n

Code quality License Code coverage Reference documentation Go Report Card

This is the code repository for go-i18n, a go-text wrapper joining gettext support for Linux and Windows.

This package allows to transparently embeds local translation or lookup in system path for installed translations on both platforms. It also includes a composite Github action to update translation on any folder. It will initialize and loads translation, ready to be used by gotext.

For usage in your own project, please refer to the reference documentation.

Reusable github action

A reusable action will extract any translatable strings using gotext functions in your code. Those will generate an up to date <domain>.pot file in the destination directory. Any <locale>.po file inside this directory will then be refreshed with the new available translations.

Usage example:


To bootstrap a new locale, you can cp <domain>.pot <locale>.po and commit it.

Troubleshooting

The project is using the slog package from Go 1.21. You can increase the verbosity of your embedding code to have more logs printed.

Get involved

This is an open source project and we warmly welcome community contributions, suggestions, and constructive feedback. If you're interested in contributing, please take a look at our Contribution guidelines first.

  • to report an issue, please file a bug report against our repository, using a bug template.
  • for suggestions and constructive feedback, report a feature request bug report, using the proposed template.

Get in touch

We're friendly! We have a community forum at https://discourse.ubuntu.com where we discuss feature plans, development news, issues, updates and troubleshooting.

For news and updates, follow the Ubuntu twitter account and on Facebook.

Documentation

Overview

Package i18n is responsible for internationalization/translation handling and generation.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitI18nDomain

func InitI18nDomain(domain string, poDir fs.FS)

InitI18nDomain loads domain for the user current locale. If a poDir is passed as fs.FS, then, it will override for the domain any translations potentially present on disk.

Example
i18n.InitI18nDomain("domain", nil)
fmt.Println(gotext.Get("some strings"))
Example (EmbeddedFiles)
i18n.InitI18nDomain("apt", po.Files)
fmt.Println(gotext.Get("unknown"))

Types

This section is empty.

Directories

Path Synopsis
cmd
compile-mo command
package main implements compile-mo command line to compile localised po file to mo via gettext.
package main implements compile-mo command line to compile localised po file to mo via gettext.
update-po command
package main implements update-po command line to update one domain pot file and merge with any existing translations.
package main implements update-po command line to update one domain pot file and merge with any existing translations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL