Localize entire string

Is there a similar function in Xojo as phps printf?
For example: printf(“Some text %s translation %s”, $string, $string)
Need it to localize strings.

Not like this.

Check in the documentation about Constants: you can set a string constant with more than one value, like:
English value, Spanish value, German value, French value

Then, at compile time, you will get a new file in the Libs directory (Windows) who holds these values and fr.lproj, de.lproj, en.lproj, ect in the OS X application bundle (folder).

Make sure to check the “Dynamic” checkbox for the constants :slight_smile:

I’ve solved this by using replace a lot: replace(kErrorMessage, “<>”, application.appname) or similar, where kErrorMessage is the dynamic constant that Emile and Albin mentioned. Which was pretty annoying. Are you up for a Feedback request?

No.

You may know that you can export a module as xml. Then you can open it with your text editor and add / remove / make changes at will (if you follow that file xml rules).

I re-think at that lately. ('cause I forgot).

@Emile: “no” what?

I created my own version of the Mac OS Classic ParamText function to help with this. Each piece of dynamic data is referenced in the string using a caret ^ and an incrementing number.

so… If I needed to include two pieces of dynamic data in my message I would have a string constant like this:
“Uploading File ^0 Of ^1”

I could then use the function in this way:
MsgBox(ParamText(kMyStringConstant, data1, data2))

The ParamText function would look something like this:

Protected Function ParamText(pSourceString As String, ParamArray pParams As String) As String
Dim itemCount As Integer
Dim theParam As String

itemCount = 0
For Each theParam In pParams
pSourceString = ReplaceAll(pSourceString, “^” + Str(itemCount), theParam)
itemCount = itemCount + 1
Next

Return pSourceString
End Function

This is how I currently do it.

The bug report. Sorry.