最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Cloud translate JSON file - Stack Overflow

programmeradmin3浏览0评论

I would like to translate the fields of a posite 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"
    }
}

I would like to translate the fields of a posite 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"
    }
}
Share Improve this question asked Jul 16, 2018 at 13:40 Andrea GrippiAndrea Grippi 1,6096 gold badges17 silver badges27 bronze badges 1
  • 1 You could look into github./fkirc/attranslate. "attranslate" is a simple tool for translating JSON-files, and it also supports Google Cloud. – Mike76 Commented Apr 9, 2022 at 10:28
Add a ment  | 

3 Answers 3

Reset to default 3

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

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.

{ "meta": { "language": "German", "language_locale": "Deutsch", "author": "Maskabor (www.kvor)", "gameversion": "1.0" }, "stats": { "ammoCost": "Munitionskosten", "battleTier": "Gefechtsstufe", "battles": "Gefechte", "battlesInVehicle": "Gefechte im Panzer", "battlesWon": "Gefechte gewonnen", "bonds": "Anleihen", "bondsCost": "Anleihen ausgeg.", "bondsIne": "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", # puter translated "localesSelect": "Sprache auswählen" # puter translated } }

发布评论

评论列表(0)

  1. 暂无评论