Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Parameterizing localization strings with arguments #36

Open
metaphore opened this issue Sep 3, 2016 · 9 comments
Open

Parameterizing localization strings with arguments #36

metaphore opened this issue Sep 3, 2016 · 9 comments
Assignees
Milestone

Comments

@metaphore
Copy link
Contributor

Following this example from wiki @key|only|@arg I'm trying to pass argument to localized string as parameter:

<vislabel>@key|{arg}</vislabel>

But as result parser searches for key|{arg} key in bundle (and crushes when not found).

Am I missing something?

@czyzby
Copy link
Owner

czyzby commented Sep 4, 2016

Could you provide a code sample or a small project that recreates the issue? Or paste the complete stack trace of the exception? When I used this snippet in gdx-lml-tests, it worked fine:

<:argument key="sample" value="test"/>
<label>@bundleLineWithArgument|{sample}</label>

This prints Received argument: test. as expected.

@czyzby czyzby added the lml label Sep 5, 2016
@czyzby
Copy link
Owner

czyzby commented Sep 12, 2016

@metaphore Is this still an issue?

@metaphore
Copy link
Contributor Author

@czyzby sorry, had no time to prepare code sample and check it once again. Will do it till the end of this week

@czyzby
Copy link
Owner

czyzby commented Sep 13, 2016

Not a problem, take your time.

@metaphore
Copy link
Contributor Author

metaphore commented Sep 15, 2016

I had few experiments but for good (or bad) can't reproduce it anymore. I think it should be closed now and if problem will ever occur, I will supply you with details in that issue.

BTW, is there a way to conjunct two expressions next to each other like: @someString{someValue}?

@czyzby
Copy link
Owner

czyzby commented Sep 16, 2016

BTW, is there a way to conjunct two expressions next to each other like: @someString{someValue}?

I think that in this particular example it would currently replace someValue and look for I18N line named someStringSomeValueResult.

But labels are not multiline by default (you have to enable it first), so something like this:

<label>@someString
{someValue}</label>

...would result in a single string, joining the two inputs.

@metaphore
Copy link
Contributor Author

@czyzby probably I found what is origin problem was about. If I try to parametrize localized string with a value started with . (e.g. file extension) it results in

I18N bundle not found for bundle line: @key.arg

And I guess it's pretty obvious why - LML treats key as a bundle name. But still it looks like there is no way to put any value that starts from dot. May be is it possible to add some kind of escape character for such case?

@czyzby
Copy link
Owner

czyzby commented Apr 16, 2017

Can you post a self-contained example of a LML template and the bundle line argument that reproduce the issue, so I can test it easily? I'll look into it before the next release.

Anyway, I suggest going for a workaround for now, like using a Java method for building this particular string or avoiding parametrization (if possible) when an argument with dot is present.

@czyzby czyzby reopened this Apr 16, 2017
@czyzby czyzby self-assigned this Apr 16, 2017
@czyzby czyzby added this to the 1.9 milestone Apr 16, 2017
@metaphore
Copy link
Contributor Author

metaphore commented Apr 16, 2017

Sure, thanks. I believe this should be enough to reproduce the case:

bundle.properties

key = text {0} text

template.lml

<?xml version="1.0"?>
<!DOCTYPE label SYSTEM>

<label text="@key|.value"/>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants