Skip to content

Instantly share code, notes, and snippets.

@Kaabi
Last active May 5, 2020 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kaabi/9105205deb702ec8118d0ecca5e87512 to your computer and use it in GitHub Desktop.
Save Kaabi/9105205deb702ec8118d0ecca5e87512 to your computer and use it in GitHub Desktop.
Inserting New Language variable name & value into Codeigniter multiple languages folders
#!/bin/sh
[ -z $1 ] && echo "Language file name is missing" && exit 1
[ -z $2 ] && echo "Language variable name is missing" && exit 1
[ -z "$3" ] && echo "Language variable value is missing" && exit 1
for i in $(find . -maxdepth 1 -mindepth 1 -type d); do
if ! [ -z "$(tail -c 1 "$i/$1_lang.php")" ]; then
echo "\n" >>$i/$1_lang.php
fi
echo "\$lang['"$2"'] = '"$3"';" >>$i/$1_lang.php
echo "Edited" $i/$1_lang.php
done
@Kaabi
Copy link
Author

Kaabi commented May 5, 2020

copy add-new-lang-string.sh into Codeigniter application/languages folder

Example Usage: ./add-new-lang-string.sh email new_error_msg 'Hello World!'


  • The first argument for a language file name if there is a file called email_lang.php you only need to pass email
  • The second argument for Language variable name
  • The third argument for the language value name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment