Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8301e12
First step to migrare away from easy_localizaion
omeritzics Feb 25, 2026
9932abf
Clean un-needed files
omeritzics Feb 25, 2026
0110ecf
Merge remote-tracking branch 'origin/dev' into feature/migrate-to-flu…
omeritzics Feb 26, 2026
b68d65e
Migrate away from easy localization
omeritzics Feb 26, 2026
ecc1340
Update convert_l10n.py
omeritzics Feb 27, 2026
16870b8
Update lib/generated/app_localizations_zh.dart
omeritzics Mar 1, 2026
0305d9d
Update lib/generated/app_localizations_zh.dart
omeritzics Mar 1, 2026
bc06f74
Update lib/generated/app_localizations_en.dart
omeritzics Mar 1, 2026
b74bf3f
Update lib/generated/app_localizations_zh.dart
omeritzics Mar 1, 2026
43a3334
Delete od_output.txt
omeritzics Mar 1, 2026
847282e
Delete msg_list.txt
omeritzics Mar 1, 2026
58275ab
Delete line_debug.txt
omeritzics Mar 1, 2026
c0e5591
Delete marker_debug.txt
omeritzics Mar 1, 2026
832c1d4
Delete find_flutter.txt
omeritzics Mar 1, 2026
4b2c39e
Delete home_list.txt
omeritzics Mar 1, 2026
360a821
Delete flutter_path.txt
omeritzics Mar 1, 2026
d17b281
Delete gen_output.txt
omeritzics Mar 1, 2026
46d29cf
Delete output.txt
omeritzics Mar 1, 2026
7c0b7b1
Delete conflict_debug.txt
omeritzics Mar 1, 2026
786755a
Update lib/generated/app_localizations_pt.dart
omeritzics Mar 1, 2026
838dc81
Update lib/generated/app_localizations_en.dart
omeritzics Mar 1, 2026
2a63e39
Update lib/generated/app_localizations_en.dart
omeritzics Mar 1, 2026
7417331
Update lib/generated/app_localizations_pt.dart
omeritzics Mar 1, 2026
b716e85
Merge branch 'main' into feature/migrate-to-flutter-localization
omeritzics Mar 3, 2026
6d42656
Update lib/generated/app_localizations_zh.dart
omeritzics Mar 3, 2026
a49f4c5
Update lib/generated/app_localizations_pt.dart
omeritzics Mar 3, 2026
1a41b8e
Update lib/generated/app_localizations_pt.dart
omeritzics Mar 3, 2026
38a2ee6
Update lib/generated/app_localizations_zh.dart
omeritzics Mar 3, 2026
46e0302
Update lib/generated/app_localizations_pt.dart
omeritzics Mar 3, 2026
3f72f98
Update lib/generated/app_localizations_en.dart
omeritzics Mar 3, 2026
7dee0fb
Update lib/generated/app_localizations_zh.dart
omeritzics Mar 3, 2026
0a1a589
Update lib/generated/app_localizations_pt.dart
omeritzics Mar 3, 2026
18acb1e
Update lib/generated/app_localizations_en.dart
omeritzics Mar 3, 2026
4814698
Update lib/generated/app_localizations_en.dart
omeritzics Mar 3, 2026
7167d10
Update lib/generated/app_localizations.dart
omeritzics Mar 3, 2026
54639ce
Update lib/generated/app_localizations.dart
omeritzics Mar 3, 2026
b9ca93f
Update lib/generated/app_localizations.dart
omeritzics Mar 3, 2026
615e324
Update lib/generated/app_localizations_pt.dart
omeritzics Mar 3, 2026
1b117c4
Update lib/generated/app_localizations_pt.dart
omeritzics Mar 3, 2026
aff0cb8
Update lib/generated/app_localizations_en.dart
omeritzics Mar 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions assets/translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,14 @@
"other": "{} و{} تطبيقات أخرى قد حُدثت."
},
"apk": {
"one": "{} APK",
"two": "APKان",
"other": "{} APKs"
"one": "ملف APK",
"two": "ملفين APK",
"other": "{} ملفات APK"
},
"certificateHash": {
"one": "بصمة الشهادة",
"two": "بصمتا الشهادة",
"other": "بصمات الشهادة"
"two": "بصمتين الشهادة",
"other": "{} بصمات الشهادة"
},
"securityDisclaimerTitle": "إخلاء مسؤولية الأمان والقانوني",
"license": "الرخصة",
Expand Down
5 changes: 5 additions & 0 deletions conflict_debug.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<<<<<<< HEAD
action = Semantics(
button: true,
label: AppLocalizations.of(context)!.install,
hint: appsProvider.areDownloadsRunning()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This file appears to be a merge conflict artifact. It, along with find_flutter.txt, flutter_path.txt, gen_output.txt, and home_list.txt, seems to be a temporary or debug file that was accidentally committed. These files should be removed from the pull request and added to .gitignore to prevent them from being committed in the future.

148 changes: 148 additions & 0 deletions convert_l10n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import json
import os
import re

def to_camel_case(s):
acronyms = ["APK", "URL", "GH", "PAT", "GPL", "HTTP", "ZIP"]
for a in acronyms:
if s.startswith(a):
s = a.lower() + s[len(a):]
break
if not s:
return s
return s[0].lower() + s[1:]

def extract_placeholders(s):
# Find all {name} or {}
return re.findall(r'\{([^{}]*)\}', s)

def convert_json_to_arb(source_dir, target_dir):
if not os.path.exists(target_dir):
os.makedirs(target_dir)

# Load English first as source of truth for placeholders
en_path = os.path.join(source_dir, "en.json")
with open(en_path, 'r', encoding='utf-8') as f:
en_data = json.load(f)

# Pre-process English to determine placeholder names and types
key_metadata = {}
for key, value in en_data.items():
new_key = to_camel_case(key)
placeholders = []
if isinstance(value, str):
# Replace {} with p0, p1...
count = 0
def repl(m):
nonlocal count
p = f"p{count}"
count += 1
return p
# We want to know the names
names = extract_placeholders(value)
p_names = []
p_idx = 0
for name in names:
if name == "":
p_names.append(f"p{p_idx}")
p_idx += 1
else:
p_names.append(name)
key_metadata[new_key] = {"placeholders": p_names, "is_plural": False}
elif isinstance(value, dict) and "one" in value and "other" in value:
# Plural. We'll use 'count' and then any others
names = extract_placeholders(value['one']) + extract_placeholders(value['other'])
unique_names = []
for n in names:
if n and n not in unique_names and n != "":
unique_names.append(n)
key_metadata[new_key] = {"placeholders": unique_names, "is_plural": True}

for filename in os.listdir(source_dir):
if filename.endswith(".json") and filename not in ["package-lock.json", "package.json"]:
locale = filename.replace(".json", "")
flutter_locale = locale.replace("-", "_")

source_path = os.path.join(source_dir, filename)
target_path = os.path.join(target_dir, f"app_{flutter_locale}.arb")

with open(source_path, 'r', encoding='utf-8') as f:
data = json.load(f)

arb_data = {"@@locale": flutter_locale}

for key, value in data.items():
new_key = to_camel_case(key)
meta = key_metadata.get(new_key)
if not meta:
continue # Should not happen if en.json is complete

if isinstance(value, str):
# Replace placeholders by order
names = extract_placeholders(value)
new_value = value
# Replace {} first
p_idx = 0
while "{}" in new_value:
new_value = new_value.replace("{}", f"{{p{p_idx}}}", 1)
p_idx += 1

# Replace named placeholders if they were translated
# This is tricky. We'll replace all {anything} with meta placeholders by order.
current_placeholders = re.findall(r'\{([^{}]+)\}', new_value)
for i, old_p in enumerate(current_placeholders):
if i < len(meta['placeholders']):
new_p = meta['placeholders'][i]
# Avoid replacing if it's already correct or if it's a p0 style
if old_p != new_p:
new_value = new_value.replace(f"{{{old_p}}}", f"{{{new_p}}}")

arb_data[new_key] = new_value
if meta['placeholders']:
arb_data[f"@{new_key}"] = {
"placeholders": {p: {"type": "Object"} for p in meta['placeholders']}
}

elif isinstance(value, dict) and meta['is_plural']:
one = value.get('one', '')
other = value.get('other', '')

# Normalize placeholders in one/other
def normalize_plural_segment(seg):
if not seg: return seg
# Replace {} with {count}
seg = seg.replace("{}", "{count}")

# Find all placeholders EXCEPT 'count'
# Use a set to keep track of what we've seen if we want to replace by index
# but wait, if the same translated placeholder appears twice, we should replace both.
found_ps = []
for p in re.findall(r'\{([^{}]+)\}', seg):
if p != 'count' and p not in found_ps:
found_ps.append(p)

for i, old_p in enumerate(found_ps):
if i < len(meta['placeholders']):
new_p = meta['placeholders'][i]
if old_p != new_p:
seg = seg.replace(f"{{{old_p}}}", f"{{{new_p}}}")
return seg

one = normalize_plural_segment(one)
other = normalize_plural_segment(other)

arb_data[new_key] = f"{{count, plural, one{{{one}}} other{{{other}}}}}"
p_meta = {"count": {"type": "num"}}
for p in meta['placeholders']:
p_meta[p] = {"type": "Object"}
arb_data[f"@{new_key}"] = {"placeholders": p_meta}

with open(target_path, 'w', encoding='utf-8') as f:
json.dump(arb_data, f, ensure_ascii=False, indent=2)
print(f"Converted {filename} to app_{flutter_locale}.arb")

if __name__ == "__main__":
convert_json_to_arb(
"/home/omeritzics/Dev-Projects/Updatium/assets/translations",
"/home/omeritzics/Dev-Projects/Updatium/lib/l10n"
)
1 change: 1 addition & 0 deletions find_flutter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/omeritzics/Dev-Projects/Updatium/.flutter/bin/flutter
1 change: 1 addition & 0 deletions flutter_path.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/bin/which: no flutter in (/home/omeritzics/Dev-Projects/Updatium/depot_tools:/home/omeritzics/מסמכים/Projects/flutter/bin:/home/omeritzics/depot_tools:/home/omeritzics/מסמכים/Projects/flutter/bin:/home/omeritzics/depot_tools:/home/omeritzics/.local/bin:/home/omeritzics/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/omeritzics/.dotnet/tools:/home/omeritzics/.lmstudio/bin:/home/omeritzics/.lmstudio/bin:/home/omeritzics/.lmstudio/bin:/home/omeritzics/.lmstudio/bin:/home/omeritzics/.lmstudio/bin)
Loading
Loading