Function simple_localization::trl

source ·
pub fn trl<'a, 'b>(text: &'a str, lang: &'b str) -> &'a str
Expand description

Get translation of the text in a spesific language If translation exists returns the translation else returns the text back.

use simple_localization::trl;
 
// localization/tr_TR file exists
let text:&str = trl("Hello", "tr_TR"); // "Merhaba"
 
// localization/ar_QA file exists
let text:&str = trl("Hello", "ar_QA"); // "مرحبًا"
 
// localization/tr_TR file doesn't exists
let text:&str = trl("Hello", "tr_TR"); // "Hello"