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

Read Language File "In Reverse"?

Development and Programming

JohnD's avatar
JohnD
114 posts
14 years ago
JohnD's avatar JohnD

To access language items within a language file, we can do:

$this->EE->lang->loadfile('file_name');

$this->EE->lang->line('item_short_name');

Is there a best-practice way to reverse the second item, something like:

$this->EE->lang->line('Long Name');

so that I can get the short name for a language item from the long name. I know I could read the file with php and parse it, but I as wondering if there is an EE-native way to do it.

       
Victor Michnowicz's avatar
Victor Michnowicz
95 posts
14 years ago
Victor Michnowicz's avatar Victor Michnowicz

You may be able to grab the language data with

$this->EE->lang->language;

(or something similar). Then you can use array_search to get the key for the language line you are looking for. I have not tested it, but this may work…

$key = array_search('My Language Text', $this->EE->lang->language);
       
JohnD's avatar
JohnD
114 posts
14 years ago
JohnD's avatar JohnD

Thanks for that

       

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.