mirror of
https://github.com/ysoftdevs/fastlane2xliff.git
synced 2026-04-19 23:11:45 +02:00
fix crash when target file does not exist
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
# Author: Juraj Michalek - Y Soft RnD - http://www.ysofters.com
|
# Author: Juraj Michalek - Y Soft RnD - http://www.ysofters.com
|
||||||
# MIT License - see LICENSE.txt
|
# MIT License - see LICENSE.txt
|
||||||
|
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -53,7 +54,8 @@ def parse_resources_for_os(os_name, xliff_element):
|
|||||||
for locale_key in locale_keys:
|
for locale_key in locale_keys:
|
||||||
name = locale_key
|
name = locale_key
|
||||||
value = get_file_content(meta_path + "/en-US/" + name + ".txt")
|
value = get_file_content(meta_path + "/en-US/" + name + ".txt")
|
||||||
target = get_file_content(target_resource_path + "/" + name + ".txt")
|
|
||||||
|
target_file_name = target_resource_path + "/" + name + ".txt"
|
||||||
|
|
||||||
# Do not include keys for empty resoruces
|
# Do not include keys for empty resoruces
|
||||||
if len(value) == 0:
|
if len(value) == 0:
|
||||||
@@ -61,9 +63,11 @@ def parse_resources_for_os(os_name, xliff_element):
|
|||||||
|
|
||||||
xliff_data[name] = {
|
xliff_data[name] = {
|
||||||
'source': value,
|
'source': value,
|
||||||
'target': target
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Read translated value
|
||||||
|
if os.path.exists(target_file_name):
|
||||||
|
xliff_data[name]['target'] = get_file_content(target_resource_path + "/" + name + ".txt")
|
||||||
|
|
||||||
file_element = ET.SubElement(xliff_element, 'file')
|
file_element = ET.SubElement(xliff_element, 'file')
|
||||||
file_element.attrib['source-language'] = 'en-US'
|
file_element.attrib['source-language'] = 'en-US'
|
||||||
|
|||||||
Reference in New Issue
Block a user