WICG / translation-api

A proposal for translator and language detector APIs
Other
116 stars 5 forks source link

Glossary support #8

Open domenic opened 6 months ago

domenic commented 6 months ago

Some translation APIs provide support for a glossary of specialized terms, e.g. here is Google Cloud Translation's documentation or DeepL's.

I think it would look something like this:

const translator = await translation.createTranslator({
  sourceLanguage: "ja",
  targetLanguage: "en",
  glossary: {
    "巨人": "Titan",
    "調査兵団": "Survey Corps",
    "超大型巨人": "Colossal Titan",
    "リヴァイ兵長": "Captain Levi",
    "ウォール・シーナ": "Wall Sina"
  }
});

The example given here is translating something about the popular manga/anime Attack on Titan, using the official translations that are widely used. Note that they can definitely differ from the default translations, e.g. Google Translate gives "giant", "Research Corps", and "Super-sized giants" for the first three.

globalpai commented 2 months ago

One could leverage the Glossary for DNT (Do Not Translate), but it's worth considering having DNT as a separate list.