Skip to content

Commit

Permalink
Adding save functionality to scripts inside build/data/tags and build…
Browse files Browse the repository at this point in the history
…/data/styles
  • Loading branch information
BaseMax committed Jan 10, 2025
1 parent 5342fab commit 0a3515a
Show file tree
Hide file tree
Showing 18 changed files with 364 additions and 64 deletions.
62 changes: 62 additions & 0 deletions build/data/styles/baseline_positions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_FIRST_BASELINE",
"generate_name": "first baseline",
"text": {
"EN": [
"first baseline"
],
"FA": [
"اول خط پایه"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_BASELINE_FIRST",
"generate_name": "baseline first",
"text": {
"EN": [
"baseline first"
],
"FA": [
"خط پایه اول"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_LAST_BASELINE",
"generate_name": "last baseline",
"text": {
"EN": [
"last baseline"
],
"FA": [
"آخر خط پایه"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_BASELINE_LAST",
"generate_name": "baseline last",
"text": {
"EN": [
"baseline last"
],
"FA": [
"خط پایه آخر"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_BASELINE",
"generate_name": "baseline",
"text": {
"EN": [
"baseline"
],
"FA": [
"خط پایه"
]
}
}
]
34 changes: 9 additions & 25 deletions build/data/styles/baseline_positions.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import itertools
import os
import sys
from pathlib import Path

parent_dir = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(parent_dir))
sys.path.append(os.path.join(parent_dir))

from lang import Lang
from value import Value
from values import Values
from prebuild import Prebuild

overflow_positions = Values.And(
baseline_positions = Values.And(
[
Value().set_generate_name("first").add_text(Lang.EN, "first").add_text(Lang.FA, "اول"),
Value().set_generate_name("last").add_text(Lang.EN, "last").add_text(Lang.FA, "آخر"),
Expand All @@ -20,32 +18,18 @@
Value().set_generate_name("baseline").add_text(Lang.EN, "baseline").add_text(Lang.FA, "خط پایه"),
],
)
overflow_positions += [
baseline_positions += [
Value().set_generate_name("baseline").add_text(Lang.EN, "baseline").add_text(Lang.FA, "خط پایه"),
]

print(overflow_positions)

# https://developer.mozilla.org/en-US/docs/Web/CSS/align-items
# <baseline-position> =
# [ first | last ]? &&
# baseline


# data = {
# 'EN': [['baseline'], ['last']],
# 'FA': [['خط پایه'], ['آخر']]
# }

# def generate_ordered_strings(data):
# result = {}
# for lang, text_groups in data.items():
# combinations = itertools.product(*text_groups)
# result[lang] = [' '.join(' '.join(item) for item in combo) for combo in combinations]
# return result

# output = generate_ordered_strings(data)

# # Print the results
# for lang, strings in output.items():
# print(f"{lang}: {strings}")
if __name__ == '__main__':
strings = Prebuild.to_string(
[value.to_dict() for value in baseline_positions]
)
Prebuild.print(strings)
Prebuild.save(strings, __file__)
26 changes: 26 additions & 0 deletions build/data/styles/overflow_positions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_SAFE",
"generate_name": "safe",
"text": {
"EN": [
"safe"
],
"FA": [
"امن"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_UNSAFE",
"generate_name": "unsafe",
"text": {
"EN": [
"unsafe"
],
"FA": [
"نامناسب"
]
}
}
]
12 changes: 9 additions & 3 deletions build/data/styles/overflow_positions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os
import sys
from pathlib import Path

parent_dir = Path(__file__).resolve().parent.parent
parent_dir = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(parent_dir))
sys.path.append(os.path.join(parent_dir, "data", "styles"))

from lang import Lang
from value import Value
from prebuild import Prebuild

overflow_positions = [
Value().set_generate_name("safe").add_text(Lang.EN, "safe").add_text(Lang.FA, "امن"),
Expand All @@ -18,3 +17,10 @@
# <overflow-position> =
# unsafe |
# safe

if __name__ == '__main__':
strings = Prebuild.to_string(
[value.to_dict() for value in overflow_positions]
)
Prebuild.print(strings)
Prebuild.save(strings, __file__)
86 changes: 86 additions & 0 deletions build/data/styles/self_positions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_CENTER",
"generate_name": "center",
"text": {
"EN": [
"center"
],
"FA": [
"وسط"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_START",
"generate_name": "start",
"text": {
"EN": [
"start"
],
"FA": [
"شروع"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_END",
"generate_name": "end",
"text": {
"EN": [
"end"
],
"FA": [
"پایان"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_SELF_START",
"generate_name": "self-start",
"text": {
"EN": [
"self-start"
],
"FA": [
"شروع خود"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_SELF_END",
"generate_name": "self-end",
"text": {
"EN": [
"self-end"
],
"FA": [
"پایان خود"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_FLEX_START",
"generate_name": "flex-start",
"text": {
"EN": [
"flex-start"
],
"FA": [
"شروع فلکس"
]
}
},
{
"id": "AST_LAYOUT_ATTRIBUTE_VALUE_TYPE_FLEX_END",
"generate_name": "flex-end",
"text": {
"EN": [
"flex-end"
],
"FA": [
"پایان فلکس"
]
}
}
]
12 changes: 9 additions & 3 deletions build/data/styles/self_positions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os
import sys
from pathlib import Path

parent_dir = Path(__file__).resolve().parent.parent
parent_dir = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(parent_dir))
sys.path.append(os.path.join(parent_dir, "data", "styles"))

from lang import Lang
from value import Value
from prebuild import Prebuild

self_positions = [
Value().set_generate_name("center").add_text(Lang.EN, "center").add_text(Lang.FA, "وسط"),
Expand All @@ -28,3 +27,10 @@
# self-end |
# flex-start |
# flex-end

if __name__ == '__main__':
strings = Prebuild.to_string(
[value.to_dict() for value in self_positions]
)
Prebuild.print(strings)
Prebuild.save(strings, __file__)
17 changes: 12 additions & 5 deletions build/data/tags/countries.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import json
import sys
from pathlib import Path

parent_dir = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(parent_dir))

from prebuild import Prebuild

countries = [
{"name": "AFGHANISTAN", "code": "AF"},
{"name": "ALBANIA", "code": "AL"},
Expand Down Expand Up @@ -248,7 +253,9 @@
country["name"] = country["name"].lower().strip()
country["code"] = country["code"].lower().strip()

if __name__ == "__main__":
j = json.dumps(countries, indent=4, ensure_ascii=False)
print(j)
open(Path(__file__).stem + ".json", "w", encoding="utf-8").write(j + "\n")
if __name__ == '__main__':
strings = Prebuild.to_string(
[value.to_dict() for value in countries]
)
Prebuild.print(strings)
Prebuild.save(strings, __file__)
14 changes: 14 additions & 0 deletions build/data/tags/crossorigins.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import sys
from pathlib import Path

parent_dir = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(parent_dir))

from lang import Lang
from value import Value
from prebuild import Prebuild

crossorigins = [
Value().set_generate_name("anonymous").add_text(Lang.EN, "anonymous").add_text(Lang.FA, "ناشناس"),
Value().set_generate_name("use-credentials").add_text(Lang.EN, "use credentials").add_text(Lang.FA, "یوز کرید"),
]

if __name__ == '__main__':
strings = Prebuild.to_string(
[value.to_dict() for value in crossorigins]
)
Prebuild.print(strings)
Prebuild.save(strings, __file__)
14 changes: 14 additions & 0 deletions build/data/tags/dirs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import sys
from pathlib import Path

parent_dir = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(parent_dir))

from lang import Lang
from value import Value
from prebuild import Prebuild

dirs = [
Value().set_generate_name("ltr").add_text(Lang.EN, "ltr").add_text(Lang.EN, "left").add_text(Lang.FA, "چپ به راست").add_text(Lang.FA, "چپ"),
Value().set_generate_name("rtl").add_text(Lang.EN, "rtl").add_text(Lang.EN, "right").add_text(Lang.FA, "راست به چپ").add_text(Lang.FA, "راست"),
]

if __name__ == '__main__':
strings = Prebuild.to_string(
[value.to_dict() for value in dirs]
)
Prebuild.print(strings)
Prebuild.save(strings, __file__)
17 changes: 12 additions & 5 deletions build/data/tags/languages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import json
import sys
from pathlib import Path

parent_dir = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(parent_dir))

from prebuild import Prebuild

languages = [
{"name": "Abkhazian", "code": "ab"},
{"name": "Afar", "code": "aa"},
Expand Down Expand Up @@ -208,7 +213,9 @@
language["name"] = language["name"].lower().strip()
language["code"] = language["code"].lower().strip()

if __name__ == "__main__":
j = json.dumps(languages, indent=4, ensure_ascii=False)
print(j)
open(Path(__file__).stem + ".json", "w", encoding="utf-8").write(j + "\n")
if __name__ == '__main__':
strings = Prebuild.to_string(
[value.to_dict() for value in languages]
)
Prebuild.print(strings)
Prebuild.save(strings, __file__)
Loading

0 comments on commit 0a3515a

Please sign in to comment.