FlamingMoe
FlamingMoe

Reputation: 2994

Localizing sentences

I'm localizing a PHP project with gettext ... no problem that part. The thing is that, for example, I have this sentence "Remember password". I can put in code the next (to use gettext) : echo _("Remember password")

That will generate a line in PO file with the key "Remember password", and I will translate it in english file to "Remember password", and in spanish site to "Recordar password" in the MO files.

If in the future, I want to change that sentence and put in english "Remember password forever" (for example again) ... the issue is that the key "sentence" will be different than the english translation.

Two possible situations:

1) So, if I want to have this clean, I could change the key again, and change the PHP code again, but that is not useful.

2) In the other hand, I could use a generic key, like "Login Page - Remember", that can be used and serves for any future slightly different sentences. But this extends too much the time of "localizing", since it's not as fast as adding _(" and ")

What do you use ? Any other 3rd option ?

Thank you for your comments

Upvotes: 0

Views: 90

Answers (1)

deceze
deceze

Reputation: 521995

You pretty much have summed up the two options you have. Keep in mind that if the sentence changes in your original language, it'll probably change in the localized version as well, so you'd have to touch all occurrences of it anyway (except for typos, so don't make any).

A good strategy may be to keep the primary language in the PHP files during heavy development, since it's expected to change often. Once the app settles down somewhat, you can extract it into a PO file and replace the strings in PHP with generic placeholders. Whether this works for you or not depends on your workflow and size of the project.

Upvotes: 1

Related Questions