Open jte opened 12 years ago
Good idea. I think I have subconsciously avoided to come up with it as it's quite hard to achieve.
As you might know, translatable strings are loaded during runtime so they can't be compiled into an array like you usually do.
I can think of two ways:
I could extend this to do just that: http://forum.sa-mp.com/showpost.php?p=1982002&postcount=38
What that thing does is actually invoke a function on script start-up that initializes the arrays.
I could have the pre-compiler detect arrays with translatable strings and add initialization code somewhere.
I don't prefer doing that as I consider it as cheating. It would allow for multi-line declarations, though.
I'm almost finished with an implementation of this. However, it won't be completely effortless.
Because @"string"
basically resolves to (PreparePointer(), Pointer[0])
. Wrapping the values in Text.@()
or using the %@
format specifier will work.
I'm not too happy with this implementation, but at least it's a start!
Great. I am happy as it is.
Keeping this open as I'm looking for better ways to deal with this. Also, it doesn't work for static variables.
Like this: new arraysOfStrings[][] = { @"Example 1", @"Example 2", @"Example 3", @"Example 4" };
At the current state this crashes the compiler... I know this is possible to do like you did with CommandDescription but that's added effort :)