laratext/lib.rs
1//! Laratext for Laravel Rust: translation keys with their source text, and auto-translation with
2//! OpenAI, Claude, Google Translate or Translatorio.
3//!
4//! In Laravel, `__()` takes either the key, and the file becomes unreadable, or the text, and the
5//! translation breaks when you change a character. Laratext takes both:
6//!
7//! ```
8//! use laratext::{replace, text};
9//!
10//! text("key_name", "default_value");
11//!
12//! // A key alone makes its text: "Hello Mate".
13//! assert_eq!(text!("hello_mate"), "Hello Mate");
14//!
15//! assert_eq!(
16//! text!("items.count", "One item|You have :count items", replace! { count => 5 }),
17//! "You have 5 items"
18//! );
19//! ```
20//!
21//! `laratext:scan` reads the calls in your project and translates what is missing, and
22//! `{{ text('key', 'Default') }}` does the same in a MiniJinja template.
23//!
24//! It is the port of the PHP package [`edulazaro/laratext`](https://github.com/edulazaro/laratext)
25//! to Laravel Rust 0.1 (beta), and its API follows the framework's changes until 1.0. The current
26//! locale comes from [`laralocale`], which has to be registered as well.
27
28pub mod catalog;
29pub mod config;
30pub mod console;
31pub mod helpers;
32pub mod js;
33pub mod json;
34pub mod limits;
35pub mod locks;
36pub mod plural;
37pub mod provider;
38pub mod replace;
39pub mod scripts;
40pub mod selector;
41pub mod sources;
42pub mod support;
43pub mod text;
44pub mod translator;
45pub mod translators;
46#[cfg(feature = "minijinja")]
47pub mod views;
48
49pub use catalog::{Catalog, Lines};
50pub use config::{
51 ClaudeConfig, GoogleConfig, ModelOverride, OpenAiConfig, ScanSettings, ScriptScanSettings, TextsConfig,
52 TranslatorioConfig,
53};
54pub use helpers::text;
55pub use limits::{Json, ModelLimits};
56pub use locks::TranslationLocks;
57pub use provider::LaratextServiceProvider;
58pub use replace::{Replace, ReplaceValue, make_replacements};
59pub use scripts::{Extracted, ScriptTexts, Unreadable};
60pub use selector::choose;
61pub use text::{Frontend, Prefixes, Text};
62pub use translator::{
63 RealSleeper, Sleeper, Texts, TranslateError, Translated, Translations, Translator, log_to_console, with_messages,
64};
65pub use translators::{ClaudeTranslator, GoogleTranslator, OpenAiTranslator, TranslatorioTranslator, Translators};