2015-04-20, 11:03
EDIT:
Wrong: For checking duplicates:
Correct: Check and count if same string used more then once:
Output: http://xbmclogs.com/pcmn4pbuv
Wrong: For checking duplicates:
Correct: Check and count if same string used more then once:
PHP Code:
import polib
LANGUAGE_FILE = 'strings.po'
PO_DICT = []
po = polib.pofile(LANGUAGE_FILE)
for entry in po:
PO_ARRAY = {'msgctxt': entry.msgctxt.replace('#', ''), 'msgid': entry.msgid}
PO_DICT.append(entry.msgid)
def has_duplicates(values):
# For each element, check all following elements for a duplicate.
for i in range(0, len(values)):
count = 1
dup_str = ''
for x in range(i + 1, len(values)):
if values[i] == values[x]:
count += 1
dup_str = values[i]
if count is not 1:
print dup_str, count
# Test the has_duplicates method.
print(has_duplicates(PO_DICT))
Output: http://xbmclogs.com/pcmn4pbuv