add a new script for string management
This commit is contained in:
parent
eeec5dfa89
commit
13b81a4101
4 changed files with 34 additions and 1 deletions
33
scripts/duplicates.py
Normal file
33
scripts/duplicates.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
# load every string in the source language
|
||||||
|
# print all duplicate values to a file
|
||||||
|
|
||||||
|
cwd = os.getcwd()
|
||||||
|
source = cwd + '/../src/strings/en-us.json'
|
||||||
|
|
||||||
|
reverse = {}
|
||||||
|
duplicates = {}
|
||||||
|
|
||||||
|
with open(source) as en:
|
||||||
|
strings = json.load(en)
|
||||||
|
for key, value in strings.items():
|
||||||
|
if value not in reverse:
|
||||||
|
reverse[value] = [key]
|
||||||
|
else:
|
||||||
|
reverse[value].append(key)
|
||||||
|
|
||||||
|
for key, value in reverse.items():
|
||||||
|
if len(value) > 1:
|
||||||
|
duplicates[key] = reverse[key]
|
||||||
|
|
||||||
|
print('LENGTH: ' + str(len(duplicates)))
|
||||||
|
with open('duplicates.txt', 'w') as out:
|
||||||
|
for item in duplicates:
|
||||||
|
out.write(json.dumps(item) + ': ')
|
||||||
|
out.write(json.dumps(duplicates[item]) + '\n')
|
||||||
|
out.close()
|
||||||
|
|
||||||
|
print('DONE')
|
|
@ -11,7 +11,7 @@ langlst = os.listdir(langdir)
|
||||||
|
|
||||||
keys = []
|
keys = []
|
||||||
|
|
||||||
with open('scout.txt', 'r') as f:
|
with open('unused.txt', 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
keys.append(line.strip('\n'))
|
keys.append(line.strip('\n'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue