Skip to content

Commit

Permalink
v1.16.13.0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoMorin committed Jul 14, 2023
1 parent 94b8875 commit ae4afe8
Show file tree
Hide file tree
Showing 3 changed files with 312 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class ServiceProjectKorra(val handler: (player: Player, location: Location) -> B
ConfigManager.getConfig().getBoolean("Properties.RegionProtection.Kingdoms.ProtectDuringInvasions")
}

/**
* Registered by constructor.
*/
inner class KingdomsRegionProtector : RegionProtectionBase("Kingdoms", "Kingdoms.Respect") {
override fun isRegionProtectedReal(
player: Player,
Expand Down
70 changes: 60 additions & 10 deletions crowdin.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,72 @@
# https://pyyaml.org/wiki/PyYAMLDocumentation
# Setup: Project Settings > Facets > Python
# Or Right-click on "KingdomsX" project folder in Intellij > Add Framework Support > Python
# After doing this, wait for indexing to finish.
# Run: Right-click anywhere in this file and click "Run File in Python Console"
# Used Python version: 3.11.2
# Used libs: https://pyyaml.org/wiki/PyYAMLDocumentation

import os

import yaml


# Pyyaml doesn't indent lists: https://github.com/yaml/pyyaml/issues/234
# Ain't not fucking way...
class CrowdinDumper(yaml.Dumper):
def increase_indent(self, flow=False, indentless=False):
return super(CrowdinDumper, self).increase_indent(flow, False)


def quotePaths(dumper, data):
if "/" in data:
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='"')
else:
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='')


yaml.add_representer(str, quotePaths)

crowdinFiles = []

for subdir, _, files in os.walk(r"core/src/main/resources/guis"):
guiSourcePath = r"core/src/main/resources/guis"
for subdir, _, files in os.walk(guiSourcePath):
# Language file
crowdinFiles.append({
"source": f"/core/src/main/resources/en.yml",
"translation": f"/resources/languages/%two_letters_code%/%two_letters_code%.yml"
})

subdir = subdir.replace('\\', '/')

# GUIs
for file in files:
subdir = subdir.replace('\\', '/')
filepath = subdir + '/' + file
filepath = filepath[filepath.index("guis") + len("guis") + 1:]
translationDir = subdir[len(guiSourcePath):]

if filepath.endswith(".yml"):
if file.endswith(".yml"):
crowdinFiles.append({
"source": subdir + '/' + filepath,
"translation": f"/resources/languages/%two_letters_code%/guis/{filepath}"
"source": subdir + '/' + file,
"translation": f"/resources/languages/%two_letters_code%/guis{translationDir}/{file}"
})
print(filepath)
print(f"{subdir} - {translationDir} - {file}")

with open(r'crowdin.yml', 'w') as file:
yaml.dump(dict(files=crowdinFiles), file)
file.write("# https://developer.crowdin.com/configuration-file/\n")
file.write("# Automatically generated by crowdin.py, do not edit.\n\n")

dumper = CrowdinDumper(stream=file, default_style=None,
default_flow_style=False,
canonical=False, indent=2, allow_unicode=True,
encoding='utf-8',
explicit_start=False, explicit_end=False, sort_keys=False,
width=None, line_break=None, version=None, tags=None
)

data = dict(files=crowdinFiles)
# yaml.dump(data=data, stream=file, Dumper=dumper)

try:
dumper.open()
dumper.represent(data)
dumper.close()
finally:
dumper.dispose()
Loading

0 comments on commit ae4afe8

Please sign in to comment.