-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script for php app language copies (#40)
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |