Google Cloud translate JSON file
Asked Answered
M

4

6

I would like to translate the fields of a composite JSON object using Google Cloud Platform, instead of translating every single sentence on its own. Is it possible?

Example (from English to Italian):

Origin JSON file:

{job_description: {
    name: "Taxi driver",
    description: "like the movie"
    }
}

Output JSON file:

{job_description: {
    name: "Tassista",
    description: "Come nel film"
    }
}
Muco answered 16/7, 2018 at 13:40 Comment(1)
You could look into github.com/fkirc/attranslate. "attranslate" is a simple tool for translating JSON-files, and it also supports Google Cloud.Forgo
C
1

Translation API accepts only plain-text or HTML as a format [1].

To achieve your goal, load your JSON file as an object in your code, send the fields to the Translation API, edit the object with the translation result and then generate a JSON file from your new object.

Coagulase answered 18/7, 2018 at 10:30 Comment(3)
So basically appending them as "q" parameters to the api endpoint url? It makes sense as a solution. Still hope it could be implemented one day. Thanks for your contribute.Muco
If you are using API yes, you can also have look at client librariesCoagulase
Google translates keys when JSON being sentCrud
R
3

Here is a script I wrote to achieve this. Hope this helps someone. https://github.com/EisenVault/json-google-translate

Rhenium answered 21/7, 2020 at 4:55 Comment(0)
C
1

Translation API accepts only plain-text or HTML as a format [1].

To achieve your goal, load your JSON file as an object in your code, send the fields to the Translation API, edit the object with the translation result and then generate a JSON file from your new object.

Coagulase answered 18/7, 2018 at 10:30 Comment(3)
So basically appending them as "q" parameters to the api endpoint url? It makes sense as a solution. Still hope it could be implemented one day. Thanks for your contribute.Muco
If you are using API yes, you can also have look at client librariesCoagulase
Google translates keys when JSON being sentCrud
S
0

Need fast, automated translations for your i18n files? Try translo-cli.

https://github.com/AcutusLabs/translo-cli

This open-source CLI tool uses ChatGPT to translate your primary language file into multiple target languages, with options to skip specific terms and auto-sort results.

Siret answered 1/11 at 18:37 Comment(0)
A
-6

{ "meta": { "language": "German", "language_locale": "Deutsch", "author": "Maskabor (www.kvor.net)", "gameversion": "1.0" }, "stats": { "ammoCost": "Munitionskosten", "battleTier": "Gefechtsstufe", "battles": "Gefechte", "battlesInVehicle": "Gefechte im Panzer", "battlesWon": "Gefechte gewonnen", "bonds": "Anleihen", "bondsCost": "Anleihen ausgeg.", "bondsIncome": "Anleihen erhalten", "bondsNett": "Anleihen Gewinn", "bondsSpent": "Anleihen ausgeg.", # Shortened "capturePoints": "Eroberungspunkte", "classicBattles": "Gefechte:", "classicDef": "Abgewehrt:", "classicDmg": "Schaden:", "classicEconomy": "Gesamt", "classicGold": "Gold", "classicKills": "Abschüsse:", "classicLabelAvg": "Durchschnitt:", "classicLabelTotal": "Gesamt:", "classicLabelXpc": "XPC:", "classicSpot": "Aufgeklärt:", "classicTier": "Stufe", "classicWN8": "WN8:", "classicXP": "Erfahrung:", "consumableCost": "Ausrüstung Kosten", "creditsGross": "Kredit erhalten", "creditsNett": "Kredit Gewinn", "creditsSpent": "Kredit ausgegeben", "crewXP": "Besatzung Erfahr.", # Shortened "damage": "Schaden", "damageAssisted": "Unterstütz. schaden", # Shortened "damageSniper": "Schaden über 300m", "damageSpot": "Schaden aufgeklärt", "damageTrack": "Schaden fahrwerk", # Changed "defencePoints": "Verteidigungspunkte", "freeXP": "Freie Erfahrung", "goldGross": "Gold erhalten", "goldNett": "Gold Gewinn", "goldSpent": "Gold ausgegeben", "kills": "Abschüsse", "moe": "Erfolgsmark. Wert", "moeChange": "Erfolgsmark. Änder.", # Shortened "moeChangeFirst": "Erfolgsmark. Wert", # Shortened "moeChangeLast": "Erfolgsmark. Wert", # Shortened "moeDamage": "Erfolgsmark. Schaden", # Shortened "moeDamageWithReq": "Erfolgsmark.", # Shortened "moeDmgNeeded65": "1. Erfolgsmark.", # Shortened "moeDmgNeeded85": "2. Erfolgsmark.", # Shortened "moeDmgNeeded95": "3. Erfolgsmark.", # Shortened "moeDmgNeededNextMark": "Nächste Erfolgsmark.", # Shortened "originalXP": "Erfahrungspunkte", "placeInTeam": "Platz im Team", "potentialDamageReceived": "Pot. Schaden erhalten.", # Potentieller Schaden erhalten "repairCost": "Reparaturkosten", "shotsReceivedGold": "Premium Munition Treffer erhalten", # Too long "shotsReceivedCredits": "Treffer erhalten Kreditpunkte", # Too long "spot": "Aufgeklärt", "survived": "Überlebt", "tier": "Stufe", "tier1Below": "Stufe - 1", "tier2Below": "Stufe - 2", "tierDiff1": "1. Stufe Unterschied", "tierDiff2": "2. Stufe Unterschied", "tierDiff3": "3. Stufe Unterschied", "tierTop": "Top Stufe", # changed "WN8": "WN8", "wn8ExpectedDamage": "WN8 erwarteter Schaden", "wn8ExpectedKills": "WN8 erwartete Abschüsse", "xp": "Erfahrung" }, "interface": { "battleTypeEpic": "Großgefechte", "battleTypeFrontline": "Frontlinie", "battleTypeRandom": "Zufallsgefecht", "battleTypeRanked": "Gewertet", "battleTypeStrongholdMap": "Festung:Gefechte", "battleTypeStrongholdSkirmishes": "Bollwerk", "battleTypeTeamUnranked": "Team Gefecht", "battleTypesShown": "Gefechtsart Anzeigen", "buttonInfo": "Schaltfläche Zusatzinformation", "buttonInfoBlank": "Nichts", "buttonInfoClock": "Uhr", "buttonInfoDefault": "Standard", "buttonInfoWN8": "WN8", "font": "Schriftart", "fontSelect": "Schriftart wählen", "fontSizeSelect": "Schriftgröße wählen", "liveStatsDragText": "STRG drücken CTRL\nicht drücken", "liveStatsMOE": "FTM", "liveStatsWN8": "WN8", "noBattlesPlayed": "Gefechte gespielt", "reloadConfig": "Konfiguration laden", "reset": "Zurücksetzen", "restore": "Wiederherstellen", "setup": "EINSTELLUNGEN", "actual": "Aktuell", "expected": "Erwartet", "total": "Gesamt", "average": "Durchschnitt", "wn8SourceDistribution": "WN8 Quelle", "tierPlacement": "Stufe", "tierDifference": "Stufen Unterschied", "wn8Expected": "WN8 erwartet", "export": "Export", "exportSelect": "Exportpfad: ", "exportSavedTo": "Export gespeichert unter:", "session": "Sitzung", "buildInSessionStats": "Eingebaute Sitzungs-Statistik", "buildInSessionStatsShow": "Zeigen", "buildInSessionStatsHide": "Verbergen", "language": "Sprache", # computer translated "localesSelect": "Sprache auswählen" # computer translated } }

Antrim answered 9/2, 2022 at 23:42 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Runyan

© 2022 - 2024 — McMap. All rights reserved.