diff --git a/.github/workflows/publish_alpha.yml b/.github/workflows/publish_alpha.yml index fb96c28..784d7e8 100644 --- a/.github/workflows/publish_alpha.yml +++ b/.github/workflows/publish_alpha.yml @@ -14,6 +14,7 @@ on: - 'MANIFEST.in' - 'README.md' - 'scripts/**' + - 'translations/**' workflow_dispatch: jobs: diff --git a/.github/workflows/sync_tx.yml b/.github/workflows/sync_tx.yml new file mode 100644 index 0000000..2fd378e --- /dev/null +++ b/.github/workflows/sync_tx.yml @@ -0,0 +1,32 @@ +name: Run script on merge to dev by gitlocalize-app + +on: + workflow_dispatch: + push: + branches: + - dev + +jobs: + run-script: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + ref: dev + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - name: Run script if merged by gitlocalize-app[bot] + if: github.event_name == 'push' && github.event.head_commit.author.username == 'gitlocalize-app[bot]' + run: | + python scripts/sync_translations.py + + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Update translations + branch: dev diff --git a/scripts/prepare_translations.py b/scripts/prepare_translations.py new file mode 100644 index 0000000..46dee45 --- /dev/null +++ b/scripts/prepare_translations.py @@ -0,0 +1,53 @@ +"""this script should run every time the contents of the locale folder change +except if PR originated from @gitlocalize-app +TODO - on commit to dev +""" + +import json +from os.path import dirname +import os + +locale = f"{dirname(dirname(__file__))}/locale" +tx = f"{dirname(dirname(__file__))}/translations" + + +for lang in os.listdir(locale): + intents = {} + dialogs = {} + vocs = {} + regexes = {} + for root, _, files in os.walk(f"{locale}/{lang}"): + b = root.split(f"/{lang}")[-1] + + for f in files: + if b: + fid = f"{b}/{f}" + else: + fid = f + with open(f"{root}/{f}") as fi: + strings = [l.replace("{{", "{").replace("}}", "}") + for l in fi.read().split("\n") if l.strip() + and not l.startswith("#")] + + if fid.endswith(".intent"): + intents[fid] = strings + elif fid.endswith(".dialog"): + dialogs[fid] = strings + elif fid.endswith(".voc"): + vocs[fid] = strings + elif fid.endswith(".rx"): + regexes[fid] = strings + + os.makedirs(f"{tx}/{lang}", exist_ok=True) + if intents: + with open(f"{tx}/{lang}/intents.json", "w") as f: + json.dump(intents, f, indent=4) + if dialogs: + with open(f"{tx}/{lang}/dialogs.json", "w") as f: + json.dump(dialogs, f, indent=4) + if vocs: + with open(f"{tx}/{lang}/vocabs.json", "w") as f: + json.dump(vocs, f, indent=4) + if regexes: + with open(f"{tx}/{lang}/regexes.json", "w") as f: + json.dump(regexes, f, indent=4) diff --git a/scripts/sync_translations.py b/scripts/sync_translations.py new file mode 100644 index 0000000..9322d94 --- /dev/null +++ b/scripts/sync_translations.py @@ -0,0 +1,54 @@ +"""this script should run in every PR originated from @gitlocalize-app +TODO - before PR merge +""" + +import json +from os.path import dirname +import os + +locale = f"{dirname(dirname(__file__))}/locale" +tx = f"{dirname(dirname(__file__))}/translations" + + +for lang in os.listdir(tx): + intents = f"{tx}/{lang}/intents.json" + dialogs = f"{tx}/{lang}/dialogs.json" + vocs = f"{tx}/{lang}/vocabs.json" + regexes = f"{tx}/{lang}/regexes.json" + + if os.path.isfile(intents): + with open(intents) as f: + data = json.load(f) + for fid, samples in data.items(): + if samples: + samples = [s for s in samples if s] # s may be None + with open(f"{locale}/{lang}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + + if os.path.isfile(dialogs): + with open(dialogs) as f: + data = json.load(f) + for fid, samples in data.items(): + if samples: + samples = [s for s in samples if s] # s may be None + with open(f"{locale}/{lang}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + + if os.path.isfile(vocs): + with open(vocs) as f: + data = json.load(f) + for fid, samples in data.items(): + if samples: + samples = [s for s in samples if s] # s may be None + with open(f"{locale}/{lang}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + + if os.path.isfile(regexes): + with open(regexes) as f: + data = json.load(f) + for fid, samples in data.items(): + if samples: + samples = [s for s in samples if s] # s may be None + with open(f"{locale}/{lang}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + diff --git a/translations/en-us/dialogs.json b/translations/en-us/dialogs.json new file mode 100644 index 0000000..dcd30ec --- /dev/null +++ b/translations/en-us/dialogs.json @@ -0,0 +1,16 @@ +{ + "wallpaper.changed.dialog": [ + "enjoy your new wallpaper" + ], + "no.more.pictures.dialog": [ + "I don't have anymore pictures", + "I'm out of pictures to show you" + ], + "searching.dialog": [ + "Searching pictures about {query}", + "Searching for images with {query}" + ], + "wallpaper.fail.dialog": [ + "I don't know how to change wallpaper in this platform" + ] +} \ No newline at end of file diff --git a/translations/en-us/intents.json b/translations/en-us/intents.json new file mode 100644 index 0000000..14c0c30 --- /dev/null +++ b/translations/en-us/intents.json @@ -0,0 +1,20 @@ +{ + "picture.about.intent": [ + "(show|display|random|new) (picture|photo|image) (about|for|with) {query}", + "(show|display) me a (picture|photo|image) (about|for|with) {query}", + "(show|display) me a (random|new|other|another) (picture|photo|image) (about|for|with) {query}", + "(show|display) (random|new|other|another) (picture|photo|image) (about|for|with) {query}" + ], + "picture.random.intent": [ + "(show|display|random|new) (picture|photo|image)", + "(show|display) me a (picture|photo|image)", + "(show|display) me a (random|new|other|another) (picture|photo|image)", + "(show|display) (random|new|other|another) (picture|photo|image)" + ], + "wallpaper.about.intent": [ + "(change|random|new) (wallpaper|wall paper) (about|for|with|to) {query}" + ], + "wallpaper.random.intent": [ + "(change|random|new) (wallpaper|wall paper)" + ] +} \ No newline at end of file diff --git a/translations/en-us/vocabs.json b/translations/en-us/vocabs.json new file mode 100644 index 0000000..098259f --- /dev/null +++ b/translations/en-us/vocabs.json @@ -0,0 +1,631 @@ +{ + "ArtPorn.voc": [ + "ArtPorn", + "Art Porn", + "art " + ], + "FWEPP.voc": [ + "FWEPP", + "FWEPP", + "fwepp" + ], + "MachinePorn.voc": [ + "MachinePorn", + "Machine Porn", + "machine " + ], + "StarshipPorn.voc": [ + "StarshipPorn", + "Starship Porn", + "starship " + ], + "DessertPorn.voc": [ + "DessertPorn", + "Dessert Porn", + "dessert " + ], + "AbandonedPorn.voc": [ + "AbandonedPorn", + "Abandoned Porn", + "abandoned " + ], + "HumanPorn.voc": [ + "HumanPorn", + "Human Porn", + "human " + ], + "SpacePorn.voc": [ + "SpacePorn", + "Space Porn", + "space " + ], + "ThingsCutInHalfPorn.voc": [ + "ThingsCutInHalfPorn", + "Things Cut In Half Porn", + "things cut in half " + ], + "LakePorn.voc": [ + "LakePorn", + "Lake Porn", + "lake " + ], + "RuralPorn.voc": [ + "RuralPorn", + "Rural Porn", + "rural " + ], + "InterstellarArt.voc": [ + "InterstellarArt", + "Interstellar Art", + "interstellar art" + ], + "BridgePorn.voc": [ + "BridgePorn", + "Bridge Porn", + "bridge " + ], + "FoodPorn.voc": [ + "FoodPorn", + "Food Porn", + "food " + ], + "AmateurPhotography.voc": [ + "AmateurPhotography", + "Amateur Photography", + "amateur photography" + ], + "SportsPorn.voc": [ + "SportsPorn", + "Sports Porn", + "sports " + ], + "SpringPorn.voc": [ + "SpringPorn", + "Spring Porn", + "spring " + ], + "ComicBookPorn.voc": [ + "ComicBookPorn", + "Comic Book Porn", + "comic book " + ], + "CarPorn.voc": [ + "CarPorn", + "Car Porn", + "car " + ], + "GeekPorn.voc": [ + "GeekPorn", + "Geek Porn", + "geek " + ], + "ArtistOfTheDay.voc": [ + "ArtistOfTheDay", + "Artist Of The Day", + "artist of the day" + ], + "MilitaryPorn.voc": [ + "MilitaryPorn", + "Military Porn", + "military " + ], + "SkyPorn.voc": [ + "SkyPorn", + "Sky Porn", + "sky " + ], + "BonsaiPorn.voc": [ + "BonsaiPorn", + "Bonsai Porn", + "bonsai " + ], + "VillagePorn.voc": [ + "VillagePorn", + "Village Porn", + "village " + ], + "NZPhotos.voc": [ + "NZPhotos", + "NZ Photos", + "nz photos" + ], + "JoshuaTree.voc": [ + "JoshuaTree", + "Joshua Tree", + "joshua tree" + ], + "set.voc": [ + "set", + "change", + "make", + "use" + ], + "WinterPorn.voc": [ + "WinterPorn", + "Winter Porn", + "winter " + ], + "roadporn.voc": [ + "roadporn", + "Road Porn", + "road " + ], + "SpaceFlightPorn.voc": [ + "SpaceFlightPorn", + "Space Flight Porn", + "space flight " + ], + "SummerPorn.voc": [ + "SummerPorn", + "Summer Porn", + "summer " + ], + "AnimalPorn.voc": [ + "AnimalPorn", + "Animal Porn", + "animal " + ], + "HellscapePorn.voc": [ + "HellscapePorn", + "Hellscape Porn", + "hellscape " + ], + "DesertPorn.voc": [ + "DesertPorn", + "Desert Porn", + "desert " + ], + "PowerWashingPorn.voc": [ + "PowerWashingPorn", + "Power Washing Porn", + "power washing " + ], + "CabinPorn.voc": [ + "CabinPorn", + "Cabin Porn", + "cabin " + ], + "MotorcyclePorn.voc": [ + "MotorcyclePorn", + "Motorcycle Porn", + "motorcycle " + ], + "RoomPorn.voc": [ + "RoomPorn", + "Room Porn", + "room " + ], + "previous.voc": [ + "previous", + "before", + "go back" + ], + "AdPorn.voc": [ + "AdPorn", + "Ad Porn", + "ad " + ], + "EarthlingPorn.voc": [ + "EarthlingPorn", + "Earthling Porn", + "earthling " + ], + "AgriculturePorn.voc": [ + "AgriculturePorn", + "Agriculture Porn", + "agriculture " + ], + "ExposurePorn.voc": [ + "ExposurePorn", + "Exposure Porn", + "exposure " + ], + "CityPorn.voc": [ + "CityPorn", + "City Porn", + "city " + ], + "NewsPorn.voc": [ + "NewsPorn", + "News Porn", + "news " + ], + "NationalGeographic.voc": [ + "NationalGeographic", + "National Geographic", + "national geographic" + ], + "AmateurEarthPorn.voc": [ + "AmateurEarthPorn", + "Amateur Earth Porn", + "amateur earth " + ], + "drydockporn.voc": [ + "drydockporn", + "Drydock Porn", + "drydock " + ], + "ChurchPorn.voc": [ + "ChurchPorn", + "Church Porn", + "church " + ], + "ArchitecturePorn.voc": [ + "ArchitecturePorn", + "Architecture Porn", + "architecture " + ], + "Nature.voc": [ + "Nature", + "Nature", + "nature" + ], + "MegalithPorn.voc": [ + "MegalithPorn", + "Megalith Porn", + "megalith " + ], + "InstrumentPorn.voc": [ + "InstrumentPorn", + "Instrument Porn", + "instrument " + ], + "GeologyPorn.voc": [ + "GeologyPorn", + "Geology Porn", + "geology " + ], + "HistoryPorn.voc": [ + "HistoryPorn", + "History Porn", + "history " + ], + "SteamPorn.voc": [ + "SteamPorn", + "Steam Porn", + "steam " + ], + "AutumnPorn.voc": [ + "AutumnPorn", + "Autumn Porn", + "autumn " + ], + "AdrenalinePorn.voc": [ + "AdrenalinePorn", + "Adrenaline Porn", + "adrenaline " + ], + "PolicePorn.voc": [ + "PolicePorn", + "Police Porn", + "police " + ], + "RandomKeyword.voc": [ + "random" + ], + "FirePorn.voc": [ + "FirePorn", + "Fire Porn", + "fire " + ], + "BookPorn.voc": [ + "BookPorn", + "Book Porn", + "book " + ], + "DestructionPorn.voc": [ + "DestructionPorn", + "Destruction Porn", + "destruction " + ], + "MicroPorn.voc": [ + "MicroPorn", + "Micro Porn", + "micro " + ], + "TelevisionPosterPorn.voc": [ + "TelevisionPosterPorn", + "Television Poster Porn", + "television poster " + ], + "BotanicalPorn.voc": [ + "BotanicalPorn", + "Botanical Porn", + "botanical " + ], + "GamerPorn.voc": [ + "GamerPorn", + "Gamer Porn", + "gamer " + ], + "AerialPorn.voc": [ + "AerialPorn", + "Aerial Porn", + "aerial " + ], + "sculptureporn.voc": [ + "sculptureporn", + "Sculpture Porn", + "sculpture " + ], + "UniformPorn.voc": [ + "UniformPorn", + "Uniform Porn", + "uniform " + ], + "AVPorn.voc": [ + "AVPorn", + "AV Porn", + "av " + ], + "BoatPorn.voc": [ + "BoatPorn", + "Boat Porn", + "boat " + ], + "SeaPorn.voc": [ + "SeaPorn", + "Sea Porn", + "sea " + ], + "RetailPorn.voc": [ + "RetailPorn", + "Retail Porn", + "retail " + ], + "RidesPorn.voc": [ + "RidesPorn", + "Rides Porn", + "rides " + ], + "BeachPorn.voc": [ + "BeachPorn", + "Beach Porn", + "beach " + ], + "wallpapers.voc": [ + "wallpapers", + "wallpaper", + "wall paper", + "wall papers" + ], + "TeaPorn.voc": [ + "TeaPorn", + "Tea Porn", + "tea " + ], + "ClimbingPorn.voc": [ + "ClimbingPorn", + "Climbing Porn", + "climbing " + ], + "NatureGifs.voc": [ + "NatureGifs", + "Nature Gifs", + "nature gifs" + ], + "remoteplaces.voc": [ + "remoteplaces", + "Remote Places", + "remote places" + ], + "ImaginaryLandscapes.voc": [ + "ImaginaryLandscapes", + "Imaginary Landscapes", + "imaginary landscapes" + ], + "OrganizationPorn.voc": [ + "OrganizationPorn", + "Organization Porn", + "organization " + ], + "MushroomPorn.voc": [ + "MushroomPorn", + "Mushroom Porn", + "mushroom " + ], + "InfraredPorn.voc": [ + "InfraredPorn", + "Infrared Porn", + "infrared " + ], + "F1Porn.voc": [ + "F1Porn", + "Formula1 Porn", + "formula1 " + ], + "HousePorn.voc": [ + "HousePorn", + "House Porn", + "house " + ], + "ViewPorn.voc": [ + "ViewPorn", + "View Porn", + "view " + ], + "MTGPorn.voc": [ + "MTGPorn", + "MTG Porn", + "mtg " + ], + "EyeCandy.voc": [ + "EyeCandy", + "Eye Candy", + "eye candy" + ], + "Schweiz.voc": [ + "Schweiz", + "Schweiz", + "schweiz" + ], + "KnifePorn.voc": [ + "KnifePorn", + "Knife Porn", + "knife " + ], + "FossilPorn.voc": [ + "FossilPorn", + "Fossil Porn", + "fossil " + ], + "CemeteryPorn.voc": [ + "CemeteryPorn", + "Cemetery Porn", + "cemetery " + ], + "IncredibleIndia.voc": [ + "IncredibleIndia", + "Incredible India", + "incredible india" + ], + "MoviePosterPorn.voc": [ + "MoviePosterPorn", + "Movie Poster Porn", + "movie poster " + ], + "ITookAPicture.voc": [ + "ITookAPicture", + "I Took A Picture", + "i took a picture" + ], + "BackgroundArt.voc": [ + "BackgroundArt", + "Background Art", + "background art" + ], + "MacroPorn.voc": [ + "MacroPorn", + "Macro Porn", + "macro " + ], + "LavaPorn.voc": [ + "LavaPorn", + "Lava Porn", + "lava " + ], + "EarthPornVids.voc": [ + "EarthPornVids", + "Earth Porn Vids", + "earth vids" + ], + "EarthPorn.voc": [ + "EarthPorn", + "Earth Porn", + "earth " + ], + "ToolPorn.voc": [ + "ToolPorn", + "Tool Porn", + "tool " + ], + "InfrastructurePorn.voc": [ + "InfrastructurePorn", + "Infrastructure Porn", + "infrastructure " + ], + "StreetArtPorn.voc": [ + "StreetArtPorn", + "Street Art Porn", + "street art " + ], + "DesignPorn.voc": [ + "DesignPorn", + "Design Porn", + "design " + ], + "WaterPorn.voc": [ + "WaterPorn", + "Water Porn", + "water " + ], + "WeatherPorn.voc": [ + "WeatherPorn", + "Weather Porn", + "weather " + ], + "ApocalypsePorn.voc": [ + "ApocalypsePorn", + "Apocalypse Porn", + "apocalypse " + ], + "FuturePorn.voc": [ + "FuturePorn", + "Future Porn", + "future " + ], + "ImaginaryWildlands.voc": [ + "ImaginaryWildlands", + "Imaginary Wildlands", + "imaginary wildlands" + ], + "MetalPorn.voc": [ + "MetalPorn", + "Metal Porn", + "metal " + ], + "AlbumArtPorn.voc": [ + "AlbumArtPorn", + "Album Art Porn", + "album art " + ], + "GunPorn.voc": [ + "GunPorn", + "Gun Porn", + "gun " + ], + "FashionPorn.voc": [ + "FashionPorn", + "Fashion Porn", + "fashion " + ], + "next.voc": [ + "next", + "after" + ], + "CulinaryPorn.voc": [ + "CulinaryPorn", + "Culinary Porn", + "culinary " + ], + "TechnologyPorn.voc": [ + "TechnologyPorn", + "Technology Porn", + "technology " + ], + "SpecArt.voc": [ + "SpecArt", + "Spec Art", + "spec art" + ], + "ArtefactPorn.voc": [ + "ArtefactPorn", + "Artefact Porn", + "artefact " + ], + "Conservation.voc": [ + "Conservation", + "Conservation", + "conservation" + ], + "FractalPorn.voc": [ + "FractalPorn", + "Fractal Porn", + "fractal " + ], + "NaturePics.voc": [ + "NaturePics", + "Nature Pics", + "nature pics" + ], + "NotSafeForNature.voc": [ + "NotSafeForNature", + "Not Safe For Nature", + "not safe for nature" + ], + "QuotesPorn.voc": [ + "QuotesPorn", + "Quotes Porn", + "quotes " + ] +} \ No newline at end of file