netbe / Babelish

Chaotically confused, like Babel
http://netbe.github.io/Babelish
MIT License
254 stars 84 forks source link

Placeholders? #108

Closed sonicdebris closed 4 years ago

sonicdebris commented 6 years ago

I am using babelish to generate android xml, ios .string and web json string files from a single csv.

How to handle placeholders? On android I need them to be in the form %s, and on ios in the form %@.

Is babelish capable of handling this situation? Should I use a specific "placeholder string sequence" to correctly export it to the various formats?

netbe commented 6 years ago

Hi,

Usually I use different csv for each platform so each csv will contain the specific placeholders.

So right now it is not possible to handle this situation, but if you have a good idea to do that, you're welcome to open a PR ;)

sonicdebris commented 6 years ago

We are trying to have one single source of truth for the texts in our app, so I would like to avoid having two places where we have to edit the same string only because the placeholders are different.

I will try and see if I can add what I need. Any pointer on where I could "plug" some check+substitution of the placeholders? It seems to me that process_value(row_value, default_value) would be a good place for that.

netbe commented 6 years ago

@sonicdebris yes, that's the place where to deal with it. which syntax are you going to keep? iOS or Android or something new?

sonicdebris commented 6 years ago

I will check with our iOS and web developers (I work with android) and try to understand which platform's syntax can be translated to the others without loss of information.

On android, we can have %d for integers, and %s$1, %s$2 and so on for multiple variables, plus the xml format has some restrictions like some characters that need to be escaped.

So I am leaning towards keeping the android syntax, but we'll see.

sonicdebris commented 6 years ago

Ok, apparently iOS also supports the same format as Android (with %d, %s, %1$s, %2$d and so on). On web, our team uses the {n} format for the placeholders, but they pointed out that it's just one of the many possible choices, since there's not a single way to handle that.

So I will use the android/ios format in the csv, but I don't know if it's worth to have a specific output web format enforced by babelish.