Giter VIP home page Giter VIP logo

Comments (7)

Mardoxx avatar Mardoxx commented on August 21, 2024
String sConcatHello = "$HELLO"
Debug.Trace( sConcatHello + " world" )

Would log
$Hello world

However, if you sent this to the UI (e.g. AddHeaderOption(sConcatHello + " world")) and had your translation file as

$Hello  Bonjour
$Hello world    Hi to the world

it would display as
Hi to the world
since the string it was sending to the UI would be "$Hello world" which is present in the translation table.

The translation isn't done in Papyrus, that wouldn't be sensible because of string caching and case insensitivity. The "translate strings" (i.e. those beginning with a $) are sent to the Scaleform VM and processed there for translation when they're set to a text field.

What is it you are wanting to translate? We (schlangster) recently implemented a, currently undocumented, nested translation system which may be of use.

from skyui.

yaiws-com avatar yaiws-com commented on August 21, 2024

Well. Something fairly simple. I have text that is concatenated with integers and floats.

string Function decimalDaysToString( Float afDays )
Return Math.Floor( afDays ) + "$DAYS" + (( afDays * 24.0 ) as Int % 24 ) + "$HOURS"
EndFunction

from skyui.

Mardoxx avatar Mardoxx commented on August 21, 2024

Ah yes, I never thought of something like that!

Leave it with us and we'll see if there's a neat way you can do it.

from skyui.

yaiws-com avatar yaiws-com commented on August 21, 2024

Cool. Thanks!

from skyui.

Mardoxx avatar Mardoxx commented on August 21, 2024

Ok here we go, in your translate files have something like
$MYMOD_DAYS{}_HOURS{} Days: {}, Hours: {}

Then in your code, use a function like this to generate your translate string,

string function translateDaysHours(float a_days)
    ; This function returns the string $MYMOD_DAYS{days}_HOURS{hours}
    return "$MYMOD_DAYS{" + Math.floor(a_days) as string + "}_HOURS{" + (( a_days * 24.0 ) as int % 24 ) as string + "}"
endFunction

and when using something like AddHeaderOption() you can do

float days = 125.4546
...
AddHeaderOption(translateDaysHours(days))

Basically, the {} work as delimiters for replacers, it's a vulgar type of a format string where anything within the curly braces will replace the curly braces in the translate string's value after being, themselves, passed through the translator. We use it for our default text, to avoid having lots of unique translate strings: Our translate files contain $SKI_INFO1{} Default: {} So we can do things like SetInfoText("$SKI_INFO1{0}") and it will display Default: 0 or even SetInfoText("$SKI_INFO1{$On}") so it yields Default: On

I hope this makes sense!

from skyui.

yaiws-com avatar yaiws-com commented on August 21, 2024

Actually, it makes perfect sense. Thanks!

from skyui.

Mardoxx avatar Mardoxx commented on August 21, 2024

Excellent 😄

from skyui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.