Skip to content

An R object model for source text and translations. Find and extract translatable strings. Provide translations and seamlessly retrieve them at runtime.

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

jeanmathieupotvin/transltr

Repository files navigation

transltr

CRAN status Lifecycle: maturing Codecov check-standard

An alternative to gettext() and xgettext() that enables support of many languages in any R application. Find, and extract source text that requires translation. Store, structure, and manipulate source texts and translations via R6 classes exposing a user-friendly API. Easily export and import to/ from a plain text format that fosters collaboration with other non-technical and external collaborators.

Why transltr?

There is no way GNU gettext can be replaced. This is well-designed software that exposes an extensive set of functionalities. It is ubiquitous, and has withstood the test of time. Its relevance within the R programming language is unquestionable, and it is not the objective of transltr to replace it. Instead, it aims to provide a much-lighter alternative for simpler use cases. But why?

❌ Trying to extend gettext() to functions other than stop(), warning(), and message() usually leads to fragile and incomplete ad-hoc implementations.

❌ R's Native Language Support (NLS) functionalities are not always intuitive, and their documentation is scattered across many manual pages of package base and tools.

❌ There is no easy way to inspect, and manipulate information found in Portable Object (.po) files (without writing a lot of code).

❌ Portable Objects are not intuitive for non-technical collaborators.

❌ Changing an R session's locale is not always a good idea when the intent is to merely display source text in another language. Doing so may lead to undefined behavior.

❌ R offers no way to decouple languages used for backend and frontend purposes. For example, the user interface of a Shiny application could be displayed in a language that differs from the server's internal locale.

transltr::translate() works everywhere. It can always be located, and extracted automatically with transltr::find_source().

transltr features are centralized, and thoroughly documented, even internal ones.

transltr stores, and structures source text and translations as regular R objects. They can easily be inspected, modified, imported, and exported.

transltr uses an intuitive plain text format that is (more) easily sharable, maintainable, and modifiable, even by non-technical collaborators.

transltr leaves the underlying locale unchanged.

transltr may be used in conjunction with R's NLS features, keeping front-end translations separate from back-end messages, logs, etc.

transltr only uses three carefully chosen dependencies: digest, R6, and yaml.

Installation

The plan is to submit transltr to CRAN for the first time in late November 2024. Until further notice, please do not attempt to use it. It should be considered as being in a pre-beta stage until further notice.

Usage

Write your programs as you normally would. Whenever you require a piece of text to be translated at runtime, wrap it with transltr::translate().

This section will be completed later.

Architecture

The following diagram gives an overview of how the package works.

Bugs and feedback

Submit them here. Thank you for your collaboration.

About

An R object model for source text and translations. Find and extract translatable strings. Provide translations and seamlessly retrieve them at runtime.

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Languages