PDA

View Full Version : localization questions


lenglel
18th Feb 2011, 03:19 AM
:help:
I'm working on a new mod and I want to add localization so it can
be translated into other languages.
This is my basic localization code:
private const string sLocalizationKey = "Sims3/Gameplay/Objects/Decorations/Mimics/LWEBaseClass";
//methods
public static string LocalizeString(string name, params object[] parameters)
{
string key = sLocalizationKey + ":" + name;
string localizedString = "";

if (Localization.HasLocalizedString(key))
localizedString = Localization.LocalizeString(key, parameters);
else localizedString = name;

return localizedString;
}

public static string Localize(string name)
{
return Localize(name, new object[0]);
}

public static string Localize(string name, params object[] parameters)
{
return LocalizeString("Sims3/Gameplay/Objects/Decorations/Mimics/LWEBaseClass" + name, parameters);
}



This is an example of how it is used:
SimpleMessageDialog.Show(Localize("LWEInteraction.run()"), Localize("theActor == null"));

How do I get something in my pie menu besides the key+name?
I think it has something to do with the stbl resources in the package,
but what you see here is all I've been able to get from the scripting
tutorials. I haven't found a specific tutorial aimed at localization.

Is there a tutorial on this subject somewhere, or can someone offer
some advice on the subject? I'd rather not do an English-only mod.

Buzzler
18th Feb 2011, 06:48 AM
How do I get something in my pie menu besides the key+name?You need to have an STBL resource (or 0x16 to be precise) for the game to fetch the localized strings. In the STBL, the key is the FNV64 hash of your string key, and the value is of course your localized string. I just wanted to point you to twallan's STBL compiler, so you can just write key and string into a simple XML file and let it build the STBL for. Buuut, twallan seems to have pulled it. That's very unfortunate.

Ok, in the STBL resource: hex key = FNV hash of your string key
Instance ID of the STBL resource itself: first byte = language code, e.g. 00 for English; last 7 bytes = Until now I just used FNV64 hash of "Buzz_{NameOfMod}_Strings" or something for my mods and cut off the first byte. Worked so far, but I'm going to ask Peter Jones how he does it in S3OC and if there's some more to it.

Is there a tutorial on this subject somewhere, or can someone offer some advice on the subject?Well, I am planning to write a tutorial on the matter. I wanted to do it today actually. That twallan's STBL compiler isn't available anymore, is kind of a setback, though.

lenglel
18th Feb 2011, 08:58 PM
Thanks bunches, Buzzler. I found the link you posted to the tutorial
in today's new posts, and Twallan posted his compiler.

Another problem with this mod is routing to the custom object. I've
seen my sim use it with a wall in between them, using this code:
//route sim to {redacted} if not in inventory
Route r = theActor.CreateRoute();
//r.AddObjectToIgnoreForRoute(this.mJig.ObjectId);
r.PlanToPointRadialRange(this, this.PositionOnFloor, 0.3f, 1.0f);
theActor.DoRoute(r);
while (theActor.IsRouting) ;


Is there a simple way to make sure the sim goes to the room the
object is in, instead of reaching through the wall? Or should I
start a new thread for this one?

Thanks again for all your help. I'll check back here when I'm done
cooking my stbl resources. :beer:

Buzzler
18th Feb 2011, 09:31 PM
Is there a simple way to make sure the sim goes to the room the object is in, instead of reaching through the wall?I'd say simply use Sim.RouteToObjectRadius() or one of the other Sim.RouteTo methods. They're boolean return types, so you can just write
if (!theActor.RouteToObjectAndCheckInUse(...)) { /* failed, so bail out */ }
// continue with whatever you're doing


If you have further questions, it's probably better to start a new thread, though. ;)