Add gettext context to tags and warnings, update translations

This commit is contained in:
rubenwardy 2024-06-09 13:48:00 +01:00
parent 36644216b2
commit 8b6bd8d282
42 changed files with 36546 additions and 10680 deletions

@ -1,126 +1,248 @@
# THIS FILE IS AUTOGENERATED: utils/extract_translations.py
from flask_babel import gettext
from flask_babel import pgettext
gettext("Jam / Game 2023")
gettext("Entries to the 2023 Minetest Game Jam ")
gettext("Server Moderation and Tools")
gettext("Helps with server maintenance and moderation")
gettext("Player vs Player (PvP)")
gettext("Designed to be played competitively against other players")
gettext("Player Effects / Power Ups")
gettext("For content that changes player effects, including physics, for example: speed, jump height or gravity.")
gettext("Joke")
gettext("For humorous content, meant as a novelty or joke, not to be taken seriously, and that is not meant to be used seriously or long-term.")
gettext("Shooter")
gettext("First person shooters (FPS) and more")
gettext("Mapgen / Biomes / Decoration")
gettext("New mapgen or changes mapgen")
gettext("Singleplayer-focused")
gettext("Content that can be played alone")
gettext("World Maintenance and Tools")
gettext("Tools to manage the world")
gettext("Developer Tools")
gettext("Tools for game and mod developers")
gettext("Adventure / RPG")
gettext("Crafting")
gettext("Big changes to crafting gameplay")
gettext("Sounds / Music")
gettext("Focuses on or adds new sounds or musical things")
gettext("Inventory")
gettext("Changes the inventory GUI")
gettext("Chat / Commands")
gettext("Focus on player chat/communication or who's primary function is interacting with the console.")
gettext("Plants and Farming")
gettext("Adds new plants or other farmable resources.")
gettext("Complex installation")
gettext("Requires futher installation steps, such as installing luarocks or editing the trusted mod setting")
gettext("Multiplayer-focused")
gettext("Can/should only be used in multiplayer")
gettext("Tools / Weapons / Armor")
gettext("Adds or changes tools, weapons, and armor")
gettext("Sims")
gettext("Mods and games that aim to simulate real life activity. Similar to SimCity/TheSims/OpenTTD/etc")
gettext("<16px")
gettext("Less than 16px")
gettext("Environment / Weather")
gettext("Improves the world, adding weather, ambient sounds, or other environment mechanics")
gettext("Mobs / Animals / NPCs")
gettext("Adds mobs, animals, and NPCs")
gettext("Puzzle")
gettext("Focus on puzzle solving instead of combat")
gettext("Building")
gettext("Focuses on building, such as adding new materials or nodes")
gettext("Building Mechanics and Tools")
gettext("Adds game mechanics or tools that change how players build.")
gettext("Decorative")
gettext("Adds nodes with no other purpose than for use in building")
gettext("Magic / Enchanting")
gettext("One-of-a-kind / Original")
gettext("For games and such that are of their own kind, distinct and original in nature to others of the same category.")
gettext("16px")
gettext("For 16px texture packs")
gettext("Custom mapgen")
gettext("Contains a completely custom mapgen implemented in Lua, usually requires worlds to be set to the 'singlenode' mapgen.")
gettext("HUD")
gettext("For mods that grant the player extra information in the HUD")
gettext("API / Library")
gettext("Primarily adds an API for other mods to use")
gettext("Mini-game")
gettext("Adds a mini-game to be played within Minetest")
gettext("Education")
gettext("Either has educational value, or is a tool to help teachers ")
gettext("Sports")
gettext("Storage")
gettext("Adds or improves item storage mechanics")
gettext("Survival")
gettext("Written specifically for survival gameplay with a focus on game-balance, difficulty level, or resources available through crafting, mining, ...")
gettext("Player vs Environment (PvE)")
gettext("For content designed for one or more players that focus on combat against the world, mobs, or NPCs.")
gettext("GUI")
gettext("For content whose main utility / feature is in GUI/formspec form")
gettext("64px")
gettext("For 64px texture packs")
gettext("Commerce / Economy")
gettext("Related to economies, money, and trading")
gettext("Minetest Game improved")
gettext("Forks of MTG")
gettext("Jam / Weekly Challenges 2021")
gettext("For mods created for the Discord \"Weekly Challenges\" modding event in 2021")
gettext("Transport")
gettext("Adds or changes transportation methods. Includes teleportation, vehicles, ridable mobs, transport infrastructure and thematic content")
gettext("Food / Drinks")
gettext("Machines / Electronics")
gettext("Adds machines useful in automation, tubes, or power.")
gettext("Creative")
gettext("Written specifically or exclusively for use in creative mode. Adds content only available through a creative inventory, or provides tools that facilitate ingame creation and doesn't add difficulty or scarcity")
gettext("Seasonal")
gettext("For content generally themed around a certain season or holiday")
gettext("32px")
gettext("For 32px texture packs")
gettext("Jam / Combat 2020")
gettext("For mods created for the Discord \"Combat\" modding event in 2020")
gettext("Jam / Game 2021")
gettext("Entries to the 2021 Minetest Game Jam")
gettext("128px+")
gettext("For 128px or higher texture packs")
gettext("Player customization / Skins")
gettext("Allows the player to customize their character by changing the texture or adding accessories.")
gettext("Strategy / RTS")
gettext("Games and mods with a heavy strategy component, whether real-time or turn-based")
gettext(" Jam / Game 2022")
gettext("Entries to the 2022 Minetest Game Jam ")
gettext("Gore")
gettext("Blood, etc")
gettext("Gambling")
gettext("Games of chance, gambling games, etc")
gettext("Drugs")
gettext("Contains illegal drugs, such as marijuana")
gettext("Violence")
gettext("Non-cartoon violence. May be towards fantasy or human-like characters")
gettext("Fear / Horror")
gettext("Shocking and scary content. May scare young children")
gettext("Bad Language")
gettext("Contains swearing")
gettext("Alcohol / Tobacco")
gettext("Contains alcohol and/or tobacco")
# NOTE: tags: title for jam_game_2023
pgettext("tags", "Jam / Game 2023")
# NOTE: tags: description for jam_game_2023
pgettext("tags", "Entries to the 2023 Minetest Game Jam ")
# NOTE: tags: title for server_tools
pgettext("tags", "Server Moderation and Tools")
# NOTE: tags: description for server_tools
pgettext("tags", "Helps with server maintenance and moderation")
# NOTE: tags: title for pvp
pgettext("tags", "Player vs Player (PvP)")
# NOTE: tags: description for pvp
pgettext("tags", "Designed to be played competitively against other players")
# NOTE: tags: title for player_effects
pgettext("tags", "Player Effects / Power Ups")
# NOTE: tags: description for player_effects
pgettext("tags", "For content that changes player effects, including physics, for example: speed, jump height or gravity.")
# NOTE: tags: title for world_tools
pgettext("tags", "World Maintenance and Tools")
# NOTE: tags: description for world_tools
pgettext("tags", "Tools to manage the world")
# NOTE: tags: title for april_fools
pgettext("tags", "Joke")
# NOTE: tags: description for april_fools
pgettext("tags", "For humorous content, meant as a novelty or joke, not to be taken seriously, and that is not meant to be used seriously or long-term.")
# NOTE: tags: title for shooter
pgettext("tags", "Shooter")
# NOTE: tags: description for shooter
pgettext("tags", "First person shooters (FPS) and more")
# NOTE: tags: title for adventure__rpg
pgettext("tags", "Adventure / RPG")
# NOTE: tags: title for mapgen
pgettext("tags", "Mapgen / Biomes / Decoration")
# NOTE: tags: description for mapgen
pgettext("tags", "New mapgen or changes mapgen")
# NOTE: tags: title for singleplayer
pgettext("tags", "Singleplayer-focused")
# NOTE: tags: description for singleplayer
pgettext("tags", "Content that can be played alone")
# NOTE: tags: title for developer_tools
pgettext("tags", "Developer Tools")
# NOTE: tags: description for developer_tools
pgettext("tags", "Tools for game and mod developers")
# NOTE: tags: title for crafting
pgettext("tags", "Crafting")
# NOTE: tags: description for crafting
pgettext("tags", "Big changes to crafting gameplay")
# NOTE: tags: title for sound_music
pgettext("tags", "Sounds / Music")
# NOTE: tags: description for sound_music
pgettext("tags", "Focuses on or adds new sounds or musical things")
# NOTE: tags: title for inventory
pgettext("tags", "Inventory")
# NOTE: tags: description for inventory
pgettext("tags", "Changes the inventory GUI")
# NOTE: tags: title for chat
pgettext("tags", "Chat / Commands")
# NOTE: tags: description for chat
pgettext("tags", "Focus on player chat/communication or who's primary function is interacting with the console.")
# NOTE: tags: title for plants_and_farming
pgettext("tags", "Plants and Farming")
# NOTE: tags: description for plants_and_farming
pgettext("tags", "Adds new plants or other farmable resources.")
# NOTE: tags: title for complex_installation
pgettext("tags", "Complex installation")
# NOTE: tags: description for complex_installation
pgettext("tags", "Requires futher installation steps, such as installing luarocks or editing the trusted mod setting")
# NOTE: tags: title for multiplayer
pgettext("tags", "Multiplayer-focused")
# NOTE: tags: description for multiplayer
pgettext("tags", "Can/should only be used in multiplayer")
# NOTE: tags: title for tools
pgettext("tags", "Tools / Weapons / Armor")
# NOTE: tags: description for tools
pgettext("tags", "Adds or changes tools, weapons, and armor")
# NOTE: tags: title for simulation
pgettext("tags", "Sims")
# NOTE: tags: description for simulation
pgettext("tags", "Mods and games that aim to simulate real life activity. Similar to SimCity/TheSims/OpenTTD/etc")
# NOTE: tags: title for magic
pgettext("tags", "Magic / Enchanting")
# NOTE: tags: title for less_than_px
pgettext("tags", "<16px")
# NOTE: tags: description for less_than_px
pgettext("tags", "Less than 16px")
# NOTE: tags: title for building_mechanics
pgettext("tags", "Building Mechanics and Tools")
# NOTE: tags: description for building_mechanics
pgettext("tags", "Adds game mechanics or tools that change how players build.")
# NOTE: tags: title for environment
pgettext("tags", "Environment / Weather")
# NOTE: tags: description for environment
pgettext("tags", "Improves the world, adding weather, ambient sounds, or other environment mechanics")
# NOTE: tags: title for mobs
pgettext("tags", "Mobs / Animals / NPCs")
# NOTE: tags: description for mobs
pgettext("tags", "Adds mobs, animals, and NPCs")
# NOTE: tags: title for puzzle
pgettext("tags", "Puzzle")
# NOTE: tags: description for puzzle
pgettext("tags", "Focus on puzzle solving instead of combat")
# NOTE: tags: title for building
pgettext("tags", "Building")
# NOTE: tags: description for building
pgettext("tags", "Focuses on building, such as adding new materials or nodes")
# NOTE: tags: title for decorative
pgettext("tags", "Decorative")
# NOTE: tags: description for decorative
pgettext("tags", "Adds nodes with no other purpose than for use in building")
# NOTE: tags: title for oneofakind__original
pgettext("tags", "One-of-a-kind / Original")
# NOTE: tags: description for oneofakind__original
pgettext("tags", "For games and such that are of their own kind, distinct and original in nature to others of the same category.")
# NOTE: tags: title for survival
pgettext("tags", "Survival")
# NOTE: tags: description for survival
pgettext("tags", "Written specifically for survival gameplay with a focus on game-balance, difficulty level, or resources available through crafting, mining, ...")
# NOTE: tags: title for hud
pgettext("tags", "HUD")
# NOTE: tags: description for hud
pgettext("tags", "For mods that grant the player extra information in the HUD")
# NOTE: tags: title for storage
pgettext("tags", "Storage")
# NOTE: tags: description for storage
pgettext("tags", "Adds or improves item storage mechanics")
# NOTE: tags: title for 16px
pgettext("tags", "16px")
# NOTE: tags: description for 16px
pgettext("tags", "For 16px texture packs")
# NOTE: tags: title for custom_mapgen
pgettext("tags", "Custom mapgen")
# NOTE: tags: description for custom_mapgen
pgettext("tags", "Contains a completely custom mapgen implemented in Lua, usually requires worlds to be set to the 'singlenode' mapgen.")
# NOTE: tags: title for library
pgettext("tags", "API / Library")
# NOTE: tags: description for library
pgettext("tags", "Primarily adds an API for other mods to use")
# NOTE: tags: title for mini-game
pgettext("tags", "Mini-game")
# NOTE: tags: description for mini-game
pgettext("tags", "Adds a mini-game to be played within Minetest")
# NOTE: tags: title for education
pgettext("tags", "Education")
# NOTE: tags: description for education
pgettext("tags", "Either has educational value, or is a tool to help teachers ")
# NOTE: tags: title for sports
pgettext("tags", "Sports")
# NOTE: tags: title for pve
pgettext("tags", "Player vs Environment (PvE)")
# NOTE: tags: description for pve
pgettext("tags", "For content designed for one or more players that focus on combat against the world, mobs, or NPCs.")
# NOTE: tags: title for jam_combat_mod
pgettext("tags", "Jam / Combat 2020")
# NOTE: tags: description for jam_combat_mod
pgettext("tags", "For mods created for the Discord \"Combat\" modding event in 2020")
# NOTE: tags: title for creative
pgettext("tags", "Creative")
# NOTE: tags: description for creative
pgettext("tags", "Written specifically or exclusively for use in creative mode. Adds content only available through a creative inventory, or provides tools that facilitate ingame creation and doesn't add difficulty or scarcity")
# NOTE: tags: title for gui
pgettext("tags", "GUI")
# NOTE: tags: description for gui
pgettext("tags", "For content whose main utility / feature is in GUI/formspec form")
# NOTE: tags: title for 64px
pgettext("tags", "64px")
# NOTE: tags: description for 64px
pgettext("tags", "For 64px texture packs")
# NOTE: tags: title for commerce
pgettext("tags", "Commerce / Economy")
# NOTE: tags: description for commerce
pgettext("tags", "Related to economies, money, and trading")
# NOTE: tags: title for mtg
pgettext("tags", "Minetest Game improved")
# NOTE: tags: description for mtg
pgettext("tags", "Forks of MTG")
# NOTE: tags: title for jam_weekly_2021
pgettext("tags", "Jam / Weekly Challenges 2021")
# NOTE: tags: description for jam_weekly_2021
pgettext("tags", "For mods created for the Discord \"Weekly Challenges\" modding event in 2021")
# NOTE: tags: title for transport
pgettext("tags", "Transport")
# NOTE: tags: description for transport
pgettext("tags", "Adds or changes transportation methods. Includes teleportation, vehicles, ridable mobs, transport infrastructure and thematic content")
# NOTE: tags: title for food
pgettext("tags", "Food / Drinks")
# NOTE: tags: title for technology
pgettext("tags", "Machines / Electronics")
# NOTE: tags: description for technology
pgettext("tags", "Adds machines useful in automation, tubes, or power.")
# NOTE: tags: title for seasonal
pgettext("tags", "Seasonal")
# NOTE: tags: description for seasonal
pgettext("tags", "For content generally themed around a certain season or holiday")
# NOTE: tags: title for 32px
pgettext("tags", "32px")
# NOTE: tags: description for 32px
pgettext("tags", "For 32px texture packs")
# NOTE: tags: title for jam_game_2021
pgettext("tags", "Jam / Game 2021")
# NOTE: tags: description for jam_game_2021
pgettext("tags", "Entries to the 2021 Minetest Game Jam")
# NOTE: tags: title for 128px
pgettext("tags", "128px+")
# NOTE: tags: description for 128px
pgettext("tags", "For 128px or higher texture packs")
# NOTE: tags: title for skins
pgettext("tags", "Player customization / Skins")
# NOTE: tags: description for skins
pgettext("tags", "Allows the player to customize their character by changing the texture or adding accessories.")
# NOTE: tags: title for strategy_rts
pgettext("tags", "Strategy / RTS")
# NOTE: tags: description for strategy_rts
pgettext("tags", "Games and mods with a heavy strategy component, whether real-time or turn-based")
# NOTE: tags: title for jam_game_2022
pgettext("tags", " Jam / Game 2022")
# NOTE: tags: description for jam_game_2022
pgettext("tags", "Entries to the 2022 Minetest Game Jam ")
# NOTE: content_warnings: title for gore
pgettext("content_warnings", "Gore")
# NOTE: content_warnings: description for gore
pgettext("content_warnings", "Blood, etc")
# NOTE: content_warnings: title for gambling
pgettext("content_warnings", "Gambling")
# NOTE: content_warnings: description for gambling
pgettext("content_warnings", "Games of chance, gambling games, etc")
# NOTE: content_warnings: title for violence
pgettext("content_warnings", "Violence")
# NOTE: content_warnings: description for violence
pgettext("content_warnings", "Non-cartoon violence. May be towards fantasy or human-like characters")
# NOTE: content_warnings: title for horror
pgettext("content_warnings", "Fear / Horror")
# NOTE: content_warnings: description for horror
pgettext("content_warnings", "Shocking and scary content. May scare young children")
# NOTE: content_warnings: title for bad_language
pgettext("content_warnings", "Bad Language")
# NOTE: content_warnings: description for bad_language
pgettext("content_warnings", "Contains swearing")
# NOTE: content_warnings: title for alcohol_tobacco
pgettext("content_warnings", "Alcohol / Tobacco")
# NOTE: content_warnings: description for alcohol_tobacco
pgettext("content_warnings", "Contains alcohol and/or tobacco")
# NOTE: content_warnings: title for drugs
pgettext("content_warnings", "Drugs")
# NOTE: content_warnings: description for drugs
pgettext("content_warnings", "Contains recreational drugs other than alcohol or tobacco")

@ -21,7 +21,7 @@ import os
import typing
from flask import url_for
from flask_babel import lazy_gettext, get_locale, gettext
from flask_babel import lazy_gettext, get_locale, gettext, pgettext
from flask_sqlalchemy.query import Query
from sqlalchemy import or_, func
from sqlalchemy.dialects.postgresql import insert
@ -987,8 +987,8 @@ class ContentWarning(db.Model):
def get_translated(self):
# Translations are automated on dynamic data using `extract_translations.py`
return {
"title": gettext(self.title),
"description": gettext(self.description),
"title": pgettext("tags", self.title),
"description": pgettext("content_warnings", self.description),
}
def as_dict(self):
@ -1019,8 +1019,8 @@ class Tag(db.Model):
def get_translated(self):
# Translations are automated on dynamic data using `extract_translations.py`
return {
"title": gettext(self.title),
"description": gettext(self.description) if self.description else "",
"title": pgettext("tags", self.title),
"description": pgettext("tags", self.description) if self.description else "",
}
def as_dict(self):

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -10,7 +10,7 @@ base_url = "https://content.minetest.net"
translations = []
def add_translations_from_api_array(path: str, fields: List[str]):
def add_translations_from_api_array(context: str, path: str, fields: List[str]):
print(f"Extracting translations from {path}")
url = base_url + path
req = requests.get(url)
@ -18,20 +18,23 @@ def add_translations_from_api_array(path: str, fields: List[str]):
for i, row in enumerate(json):
for field in fields:
if row.get(field) is not None:
translations.append(row[field])
hint = f"{context}: {field} for {row['name']}"
translations.append((context, hint, row[field]))
add_translations_from_api_array("/api/tags/", ["title", "description"])
add_translations_from_api_array("/api/content_warnings/", ["title", "description"])
add_translations_from_api_array("tags", "/api/tags/", ["title", "description"])
add_translations_from_api_array("content_warnings", "/api/content_warnings/", ["title", "description"])
with open("app/_translations.py", "w") as f:
f.write("# THIS FILE IS AUTOGENERATED: utils/extract_translations.py\n\n")
f.write("from flask_babel import gettext\n\n")
for translation in translations:
for (context, hint, translation) in translations:
escaped = translation.replace('\n', '\\n').replace("\"", "\\\"")
f.write(f"gettext(\"{escaped}\")\n")
if hint:
f.write(f"# NOTE: {hint}\n")
f.write(f"pgettext(\"{context}\", \"{escaped}\")\n")
subprocess.run(["pybabel", "extract", "-F", "babel.cfg", "-k", "lazy_gettext", "-o", "translations/messages.pot", "."])
subprocess.run(["pybabel", "extract", "-F", "babel.cfg", "-k", "lazy_gettext", "-o", "translations/messages.pot", "-c", "NOTE", "."])
subprocess.run(["pybabel", "update", "-i", "translations/messages.pot", "-d", "translations", "--no-fuzzy-matching"])