Welcome Guest, Not a member yet? Register   Sign In
how to know the un used language strings ?
#1

hi there ,

I have a very big language file

half of them are no longer used

any idea to know the unused $lang["strings"]


thanks
Reply
#2

Hi,
as I know thus far there is no standard solution available. You have to develop something by yourself.
I an developing right now a CI translation tool which will enable the translator to translate content related with page preview function.
I could think of extend this tool with a code scan function for dead strings and _lang.php files.

Let me know, if you see any synergies or possibility for a cooperation.
Reply
#3

(This post was last modified: 03-01-2015, 08:53 AM by CroNiX.)

Long way would be to search your codebase for each key of the language files $lang array.

Like if you had $lang['welcome_message'] = 'hello';

Use the IDE's search function to search for "welcome_message" for all files in /application.

A shorter, but more complicated, way would be to create a script that would include each lang file, run an array_keys() on it just to get the keys, and then the script would go through all of your files in /application using file_get_contents() or something and search for each key in the string (file). Once a key is found remove/unset it from the array that you originally stored the array_keys() in. What you have left would be the unused lang keys.
Reply
#4

Just be careful, regardless of how you search for the language keys, to note any instances in your code base in which you generate the value passed to the lang() function (or $this->lang->line() method). For example:

Code:
<?php echo lang($data['lang_key']); ?>

or

Code:
foreach ($keys as $key) {
    echo $this->lang->line($key);
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB