英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论