views:

57

answers:

2

Hello!

I'm about to start translating my vb.net application, and I don't want to use the default methods provided by Visual Studio to do so. I need my application to be very light, and it nearly doubles it size to use the resources option.

Therefore, I'm planning to use some thing like a class, of which I would have one instance per language. Since I don't want to distribute language files as separate files (I'd rather have them hard-coded), I would like to find an easy way to check if every field of the class is initialized. I was thinking of something like an Interface, where I would do something like this:

Public Interface Language
   Dim HelloMsg As String
   Dim GoodbyeMsg As String
End Interface

Public class English Implements Language
   HelloMsg = "Hello!"
   GoodbyeMsg = "Goodbye!"
End Class

It's obviously not the right way to do it (although I could use properties instead of vars), but I was wondering whether the was a way to have the compiler check that everything is translated and warn about it if not.

Anyway, maybe is there a much better way to handle this problem ?

Thanks a lot! CFP.

+1  A: 

I'm not convinced that you should dump the resource-based localization approach just because your app has grown in size. Indeed, it could've grown from 100 Kb to 200 Kb, but this is it! It won't grow this much more. And 200 Kb is nothing nowadays.

So my advice is to reconsider and go resource-based route.

Anton Gogolev
I sure could, but it is not really an option for me to increase my app size by that much...Anyway, I don't quite like the resource-based localization options. They feel over-sized, and pretty inefficient to me, especially provided that they make it pretty complicate to edit the code without Visual Studio.Do you have an idea of how I could manage without this feature?
CFP
A: 

I've decided to use a singleton class that loads a translation file, with a method that loops through all items on a form and translate on-the-fly. See Create Synchronicity source code for more details (more specifically this code file)

CFP.

CFP
Although this method doesn't allow for auto-checking for untranslated strings.
CFP