We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Localized Text (localized text string variable loader)

Development and Programming

joshuajabbour's avatar
joshuajabbour
7 posts
18 years ago
joshuajabbour's avatar joshuajabbour

The Localized Text plugin returns a localized version of the text specified by the {exp:localized_text} tag.

Example Usage This EE Code:

{exp:localized_text string="search_module_name" file="search" language="english"}

Returns this text:

Search

Parameters string - The string parameter is required. If the string parameter is omitted, no text will be returned.

The string parameter should contain the localized text key for which you want the value returned.

file - The file parameter is required. If the file parameter is omitted or invalid, the original text code contained within the string parameter will be returned.

The file parameter should contain the name of the module, plugin, or extension from which you want to pull the localized text. It should be provided exactly as it appears in the languages folder (without the prefix “lang.” or suffix “.php”).

language - The language parameter is optional. If the language parameter is omitted or invalid, the user’s default language will be used (or if the user is anonymous, the system’s default language will be used).

If the text contained within the string parameter does not exist in the specified file or language, the original text code will be returned.

Custom Language Files This plugin can be used to create custom language files.

Simply create files named “lang.my_localized_text.php” in your languages folders. (my_localized_text can be any string, though be careful to avoid conflicting with other files.) Examine an already existing language file for examples of how to setup the array keys and values.

       
joshuajabbour's avatar
joshuajabbour
7 posts
18 years ago
joshuajabbour's avatar joshuajabbour

If all you are looking to do is create custom language files, I’m in the process of creating a simpler version with much less overhead.

However, if you want to be able to show text in multiple languages, use the plugin above.

       
joshuajabbour's avatar
joshuajabbour
7 posts
18 years ago
joshuajabbour's avatar joshuajabbour

Finished the Custom Text plugin, which is similar but doesn’t allow specifying language parameters. This decreases the plugin’s overhead, as each language file only needs to be loaded once per template.

       
Sim's avatar
Sim
8 posts
18 years ago
Sim's avatar Sim

Couldn’t it rather be like this ? :

{exp:localized_text file="search" language="english"}
{lang:search_module_name}
{/exp:localized_text}

with the whole template wrapped inside the plugin’s tag pair.

       
Sim's avatar
Sim
8 posts
18 years ago
Sim's avatar Sim

I would like to use this plugin for a whole multilingual interface with over 100 variables. The above method would be definitely more handy.

       
AussieFreelancer's avatar
AussieFreelancer
72 posts
17 years ago
AussieFreelancer's avatar AussieFreelancer

I agree with Sim here, it would be great if there was a plugin that you could wrap the whole template in, that enables you to use whatever language variables you want through simply using the {lang:variable} syntax.

Does anyone know if this exists yet, as it was 11 months ago? Or maybe it is even possible in 1.6.0.. if so, could someone point me in the right direction?

Many thanks!

Patrick

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.