mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-22 09:41:32 +03:00
Merge pull request #1246 from Yubico/lint-check-keys
Check that translation keys exist in app_en.arb in translation linter
This commit is contained in:
commit
96d17b81f5
@ -15,8 +15,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
errors = []
|
||||
|
||||
@ -70,6 +71,14 @@ def check_misc(k, v):
|
||||
return errs
|
||||
|
||||
|
||||
def check_keys_exist_in_reference(reference_strings, checked_strings):
|
||||
errs = []
|
||||
for key in checked_strings.keys():
|
||||
if key not in reference_strings:
|
||||
errs.append(f"Invalid key: {key}")
|
||||
return errs
|
||||
|
||||
|
||||
def lint_strings(strings, rules):
|
||||
for k, v in strings.items():
|
||||
if v is None:
|
||||
@ -106,6 +115,11 @@ print(target, f"- checking {len(strings)} strings")
|
||||
lint_strings(strings, values.get("@_lint_rules", {}))
|
||||
check_duplicate_values(strings)
|
||||
|
||||
with open(os.path.join(os.path.dirname(target), 'app_en.arb'), encoding='utf-8') as f:
|
||||
reference_values = json.load(f)
|
||||
errors.extend(check_keys_exist_in_reference(reference_values, values))
|
||||
|
||||
|
||||
if errors:
|
||||
print()
|
||||
print(target, "HAS ERRORS:")
|
||||
|
Loading…
Reference in New Issue
Block a user