Vikas Acharya
Vikas Acharya

Reputation: 4152

how to concat two string resource in xml textview without binding

Let's say i have a info like

android:hint="Event*"

I'm trying to internationalize my app. So, I have 10 languages and in all language Event is translated So i'll put it on string resource and use it like

android:hint="@string/event"

Now, I just want to use this Event in same way sometimes and in some cases I need to append it with some special character's like * ! @ $ etc.

I don't want it to set from java file nor i like to use data binding i.e {{ }} in direct xml is there any way to concat string like

android:hint="@string/event + *"

android:hint="@string/event + !"

android:hint="@string/event + %"

if not i need to feature request android team. how to request them ?

Upvotes: 0

Views: 574

Answers (1)

Bruno
Bruno

Reputation: 4007

What you want is possible to be done statically.

But, a little search gave me this library LikeTheSalad

Extract of the README :

It allows you to do something like this:

<string name="app_name">world</string>
<string name="template_welcome_message">hello ${app_name}</string>

And then the library does this at build time:

<string name="welcome_message">hello world</string>

Upvotes: 1

Related Questions