防止谷歌翻译翻译一个变量

huangapple go评论59阅读模式
英文:

Prevent Google Translate from translating a variable

问题

I see Google Translate, both the web interface and API, translates a variable like '{userName}'. Is there a way to preserve the variable as it is?

Context: 我有一个Flutter项目,支持本地化。ARB文件包含如下条目。因为Google翻译翻译了{userName}部分(在这个示例中是西班牙语),导致应用的西班牙语版本出现问题。

  "greetingMorningWithName": "¡Buenos días, {userName}!",
  "@greetingMorningWithName": {
    "description": "带有一个参数的消息",
    "placeholders": {
      "userName": {
        "type": "String",
        "example": "Bob"
      }
    }
  },

备注:如果我将变量名称从'userName'更改为'user_Name',则不会翻译,但我想避免这样做,因为我想坚持使用驼峰命名约定。

英文:

I see Google Translate, both the web interface and API translates a variable like '{userName}'. Is there a way to preserve the variable as it is?

防止谷歌翻译翻译一个变量

Context: I have a Flutter project with localization support. The ARB file contains an entry like below. Because Google translate translates the {userName} part (to Spanish in this example), the Spanish version of the app breaks.

  "greetingMorningWithName": "Good morning, {userName}!",
  "@greetingMorningWithName": {
    "description": "A message with a single parameter",
    "placeholders": {
      "userName": {
        "type": "String",
        "example": "Bob"
      }
    }
  },

Note: If I change the variable name from 'userName' to 'user_Name', it's not translated, but I'd like to avoid it as I want to stick to the camel case convention.

答案1

得分: 2

"ARB file"不受翻译 API 支持或训练。仅支持以下格式的文件:

纯文本和HTML 也在翻译模型中训练。

您可以创建一个Glossary来使您的语法{userName}不被翻译,并使用您的自定义词典。另一个解决方法是创建一个Custom Model,在其中您可以以ARB文件格式训练模型

英文:

The ARB file is not supported nor trained by the Translation API.  These are the supported formatted files only:    

防止谷歌翻译翻译一个变量

Plain text and HTML are also trained in the translation models.  

You can create a Glossary to have your syntax {userName} to not be translated and have your customized dictionary. Another workaround is to create a Custom Model where you can train a model in ARB file format.

huangapple
  • 本文由 发表于 2023年6月8日 01:11:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76425652.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定