Skip to content

Commit

Permalink
Added script for php app language copies (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
racitup authored Mar 26, 2020
1 parent 5c4d3d9 commit 1e63825
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions maintain/cp_lang.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys, argparse

parser = argparse.ArgumentParser(description="""Copies fusionpbx webapp languages. Run with 'find <fusionpbx_dir> -name app_config.php -exec python ./cp_lang.py {} en-gb en-us \;'""")
parser.add_argument("php", help="app_config.php, app_languages.php or app_menu.php file path", type=str)
parser.add_argument("new", help="new language code", type=str)
parser.add_argument("cur", help="current language code to copy", type=str)
args = parser.parse_args()

with open(args.php, "r+") as f:
contents = f.readlines()
for index, line in enumerate(contents):
find = "['{}']".format(args.cur)
repl = "['{}']".format(args.new)
if find in line and "['fields']" not in line:
newline = line.replace(find, repl)
if newline not in contents:
contents.insert(index+1, newline)
f.seek(0)
f.writelines(contents)

0 comments on commit 1e63825

Please sign in to comment.