Linguist and static strings
Hi All ,
I need to translate my application , everithing worked fine, till i had to translate static string array.
I have a ".h" file with this decleratrion
Code:
};
I'm inserting those string into QComboBox in a .cpp file
for ( int i=0; i < 4 i++ )
{
cboxBombType->insertItem( vecBombType[i], i);
}
I've translated "Explosive" to something else , but keep on getting "Explosive" string.
Beside this all translation are OK.
How can i fix this?
Re: Linguist and static strings
Because static variables are initialized before main function is called, long before you load translators. You should have a function that initializes that array after translators are loaded.
EDIT
Or, you could use trUtf8 when using that strings. I'm not sure, but it may work.
Code:
};
...
for ( int i=0; i < 4 i++ )
{
cboxBombType->insertItem( trUtf8(vecBombType[i]), i);
}
Re: Linguist and static strings
Code:
QT_TR_NOOP("None"),
QT_TR_NOOP("Explosive"),
QT_TR_NOOP("Flare"),
QT_TR_NOOP("Smoke")
};
for ( int i=0; i < 4 i++ ){
cboxBombType->insertItem( tr(vecBombType[i]), i);
}
Re: Linguist and static strings
tried , didn't work
the static string is in a different header , i've placed it inside the project , ts file include this strings.
Translating , releasing
still same issue
Re: Linguist and static strings
didn't work, bender ,thanks
Re: Linguist and static strings
If it's in a different header then you have to pass the context to translate() and QT_TR_NOOP(). Or move those strings into the same context.
Re: Linguist and static strings
Just look at QT_TRANSLATE_NOOP() and QT_TR_NOOP() docs. They are very well documented and include clear examples.
Re: Linguist and static strings
founf what to do thanks to every one