oscar-broman / PAWN-Boilerplate

(discontinued) Solid core for a big SA-MP server script.
http://sa-mp.com/
24 stars 13 forks source link

Make arrays of strings translateable without added effort #22

Open jte opened 12 years ago

jte commented 12 years ago

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 :)

oscar-broman commented 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:

oscar-broman commented 12 years ago

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!

jte commented 12 years ago

Great. I am happy as it is.

oscar-broman commented 12 years ago

Keeping this open as I'm looking for better ways to deal with this. Also, it doesn't work for static variables.