Skip to content

Commit

Permalink
feat: upload descriptions to Crowdin
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatKawaiiSam committed Oct 12, 2024
1 parent fb896b9 commit d74c7d5
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- You can view our patterns here: [metadata.schema.json](https://github.com/LunarClient/ServerMappings/blob/master/metadata.schema.json), or take a look below and complete the field checklist:
- [ ] `id`: a lowercase string, which should match the folder name _(ex. `myserver`)_
- [ ] `name`: a string _(ex. `MyServerPvP`)_
- [ ] `description`: hook between 16 and 80 characters _(ex. `Home of Competitive Minecraft PvP`)_
- [ ] `description`: hook between 16 and 80 characters in English _(ex. `Home of Competitive Minecraft PvP`)_
- [ ] `addresses`: an array with lowercase strings _(ex. `["my.server", "your-server.com"]`)_
- You do not need to specify subdomains, Lunar Client services automatically detect them.
- [ ] `primaryAddress`: the primary address that people connect to with (please include the subdomain if required) _(ex. `mc.my.server`)_
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/validate-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
pull_request_target:
branches:
- "*"
schedule:
- cron: "0 0 * * *"

jobs:
changes:
Expand Down Expand Up @@ -70,7 +72,7 @@ jobs:
upload-servers:
name: Upload Servers
needs: [validate-servers, changes]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
if: github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event_name == 'schedule'
runs-on: ubuntu-latest

permissions:
Expand All @@ -89,9 +91,12 @@ jobs:
- name: Install Python dependencies
run: pip install -r .scripts/requirements.txt

- name: Create output folder
- name: Create server output folder
run: mkdir .out/

- name: Create Crowdin upload folder
run: mkdir -p ServerMappings/locales/

- name: Output Server Media
run: |
python .scripts/convert_media.py \
Expand All @@ -113,10 +118,24 @@ jobs:
python .scripts/create_index.py \
--servers_dir servers \
--inactive_file inactive.json \
--translations_output ServerMappings/locales/en_US.json \
--json_output .out/servers.json \
--csv_output .out/servers.csv \
--no-include_inactive
- name: Sync to Crowdin
uses: crowdin/github-action@v2
with:
upload_sources: true
upload_translations: false
download_translations: false
source: ServerMappings/locales/en_US.json
translation: ServerMappings/locales/%locale%.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: "424304"
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}

- name: Upload to Cloudflare
env:
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
Expand Down
15 changes: 14 additions & 1 deletion .scripts/create_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import csv
import json

from utils import get_all_servers
from utils import get_all_servers, collect_translations


def main():
Expand All @@ -18,6 +18,7 @@ def main():
parser.add_argument("--servers_dir", required=True, type=str)
parser.add_argument("--inactive_file", required=True, type=str)
parser.add_argument("--json_output", required=True, type=str)
parser.add_argument("--translations_output", required=True, type=str)
parser.add_argument("--csv_output", required=True, type=str)
parser.add_argument("--include_inactive", action=argparse.BooleanOptionalAction)
args = parser.parse_args()
Expand All @@ -29,6 +30,18 @@ def main():
args.include_inactive,
)

# Create a new object for translations
translations = collect_translations(servers)

# Write the new JSON object to a file
try:
json_object = json.dumps(translations, indent=4)
with open(args.translations_output, "w", encoding="utf-8") as outfile:
outfile.write(json_object)
except Exception as e:
print("Error writing to Translations: ", e)
raise

# Write to JSON file
try:
json_object = json.dumps(servers, indent=4)
Expand Down
19 changes: 18 additions & 1 deletion .scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,21 @@ def validate_wordmark(path: str, server_name: str) -> list[str]:
)


return errors
return errors


def collect_translations(servers: list[dict]) -> dict:
"""
Collects the translations from the servers list
Parameters:
servers (list): The list of servers.
Returns:
dict: A dictionary of server IDs and their descriptions.
"""
translations = {}
for server in servers:
if 'description' in server:
translations[server['id']] = { "description": server['description'] }
return translations
12 changes: 6 additions & 6 deletions docs/adding-servers/metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ An example can also be found in the root, `metadata.example.json`. This contains

Below is a table of the basic fields that are required for your server's metadata file, and a brief description of what they are.

| Field | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `id` | This is the ID for the server, discussed in the [overview](server-mappings/adding-servers/overview), this must match the name of your server's folder. |
| `name` | This is the name for your server. |
| `description` | This is the description for your server. It must be **between 16-80 characters**. |
| Field | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | This is the ID for the server, discussed in the [overview](server-mappings/adding-servers/overview), this must match the name of your server's folder. |
| `name` | This is the name for your server. |
| `description` | This is the description for your server. It must be **between 16-80 characters** and in English. The Lunar Client translation team is responsible for translating this to server other supported languages. |

### Addresses

The `addresses` array in each server object is actually an array of IP suffixes. **This should not include the subdomain for the server**.

| ✅ Correct | ❌ Incorrect |
| ✅ Correct | ❌ Incorrect |
| ------------- | ------------------ |
| `example.com` | `play.example.com` |
| `hypixel.net` | `play.hypixel.net` |
Expand Down
2 changes: 1 addition & 1 deletion servers/alphainfinity/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "alphainfinity",
"name": "Alpha Infinity",
"website": "https://alpha-infinity.fr/",
"description": "Alpha Infinity, vise le grade Alpha, avec quêtes, mondes unique.",
"description": "Alpha Infinity, aim for the Alpha rank, with quests, unique worlds.",
"addresses": [
"alpha-infinity.fr"
],
Expand Down

1 comment on commit d74c7d5

@LunarClientBot
Copy link
Collaborator

@LunarClientBot LunarClientBot commented on d74c7d5 Oct 12, 2024

Choose a reason for hiding this comment

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

📄 Documentation Deployment

Status:✅ Completed
Environment:preview
URL:https://8864c2ee.lunarclient-dev.pages.dev

Please sign in to comment.