tzdesign / deepl-localize

Auto translate $localize files with the best translation tool out there deepl
2 stars 1 forks source link

Add context as input to deepl translation requests #9

Open genox opened 8 months ago

genox commented 8 months ago

This is a simple implementation of a context buffer to (hopefully) receive more accurate translations.

tzdesign commented 7 months ago

@genox did you had better results?

I experienced the exact output. What do you think about finding the document where the translation appears as the context?

I tested it with a lot components and single words were finally correct. Do you think we should make it optional as deepl states it as alpha and has a disclaimer on it?

genox commented 7 months ago

@tzdesign Regarding putting it behind an optional flag, sure, that is a sensitive approach.

I think, generally speaking, that the more context can be provided, the more chance there is to get a good translation.

Maybe my approach is flawed, maybe using whitespaces instead of newlines would give a different result. I have no clue about the internals of how this is processed other than the stuff they write in their api docs. I was also considering writing an A4 page worth of text or have chatgpt generate one that outlines the scenario and setting of the project and "sets the tone", so to speak, and use that as a context instead of buffering strings. Or a mix of all approaches.

Did you send the source code as context? What components do you mean?

I experienced the exact output.

You mean that the translation with context matched the translation without context?

tzdesign commented 7 months ago

Yes mostly the translation were quite equal.

I send the source code within the contexts for a few examples which were wrong and they were significant better. I'm so full of projects, but my plan is to refactor this to send the files concatenated in which the translations occur.

We are actually in a process of auto translating product data on a big scale and leveraging the context. I can tell you more in a few weeks, because I have some native speakers who might verify a large set of translations for me.

tzdesign commented 7 months ago

I'm almost done with a grep script, scanning for the current translation location and have very good results. When I am done, I will make it optional to use your solution or the translation +-20 lines as context.