markus_blue_tomato Posted October 22, 2019 Share Posted October 22, 2019 Is it possible to get the value of a specific language in ProcessWire's translation tools? What I want to is following: Before printing out $key as fallback, I want to use a "fallback" language. Only after the fallback language has also no result, the $key should be printed out. //users current language is for example: german $key = "lorem_ipsum"; $string = __($key, "path/to/my/textdomain.php"); if(empty($string)) { $string = __($key, "path/to/my/textdomain.php", "english"); } echo $string; And yes I know I could put the fallback into the code as key, but I don't want this. If the fallback has to change, the customer can't do it on his own and I have to to this with a full deployment. Link to comment Share on other sites More sharing options...
markus_blue_tomato Posted October 22, 2019 Author Share Posted October 22, 2019 I found a solution which works: //users current language is for example: german // language "default" is english $key = "lorem_ipsum"; $string = __($key, "path/to/my/textdomain.php"); if($key == $string && wire('user')->language->name != "default") { wire('languages')->setLanguage('default'); $string = __($key, "path/to/my/textdomain.php"); wire('languages')->unsetLanguage(); } echo $string; 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now