Expand description
Laratext for Laravel Rust: translation keys with their source text, and auto-translation with OpenAI, Claude, Google Translate or Translatorio.
In Laravel, __() takes either the key, and the file becomes unreadable, or the text, and the
translation breaks when you change a character. Laratext takes both:
use laratext::{replace, text};
text("key_name", "default_value");
// A key alone makes its text: "Hello Mate".
assert_eq!(text!("hello_mate"), "Hello Mate");
assert_eq!(
text!("items.count", "One item|You have :count items", replace! { count => 5 }),
"You have 5 items"
);laratext:scan reads the calls in your project and translates what is missing, and
{{ text('key', 'Default') }} does the same in a MiniJinja template.
It is the port of the PHP package edulazaro/laratext
to Laravel Rust 0.1 (beta), and its API follows the framework’s changes until 1.0. The current
locale comes from laralocale, which has to be registered as well.
Re-exports§
pub use catalog::Catalog;pub use catalog::Lines;pub use config::ClaudeConfig;pub use config::GoogleConfig;pub use config::ModelOverride;pub use config::OpenAiConfig;pub use config::ScanSettings;pub use config::ScriptScanSettings;pub use config::TextsConfig;pub use config::TranslatorioConfig;pub use helpers::text;pub use limits::Json;pub use limits::ModelLimits;pub use locks::TranslationLocks;pub use provider::LaratextServiceProvider;pub use replace::Replace;pub use replace::ReplaceValue;pub use replace::make_replacements;pub use scripts::Extracted;pub use scripts::ScriptTexts;pub use scripts::Unreadable;pub use selector::choose;pub use text::Frontend;pub use text::Prefixes;pub use text::Text;pub use translator::RealSleeper;pub use translator::Sleeper;pub use translator::Texts;pub use translator::TranslateError;pub use translator::Translated;pub use translator::Translations;pub use translator::Translator;pub use translator::log_to_console;pub use translator::with_messages;pub use translators::ClaudeTranslator;pub use translators::GoogleTranslator;pub use translators::OpenAiTranslator;pub use translators::TranslatorioTranslator;pub use translators::Translators;
Modules§
- catalog
- config
- console
- The commands:
laratext:scan,laratext:lock,laratext:unlockandmake:translator, with the names, arguments and options of the PHP package, andlaratext:publish, which Laravel Rust needs for the JavaScript module. - helpers
- js
- The JavaScript module, which
laratext:publishcopies into an application and which the provider serves under/vendor/laratext/. - json
- limits
- locks
- plural
- Plural rules, generated from
Illuminate\Translation\MessageSelector::getPluralIndex()of Laravel 13.44.1. - provider
- replace
- scripts
- selector
- Laravel’s
MessageSelector: which form ofOne item|You have :count itemsa number takes. - sources
- The scanner of
text()calls in Rust and template files. - support
- text
- translator
- translators
- The translators that ship with the package, and the registry
laratext:scanpicks from. - views
- The MiniJinja functions
text()andtexts(), the equivalents of the@textand@textsBlade directives.