PHP Gettext and strings outside the functions (strings of much use)

Asked

Viewed 40 times

1

There is a way to put in .po strings outside the _e()?

For example, hypothetically, 'real' for 'dollars'. If on a page I quote real 517 times I will translate 517 times. Instead I intend to use _p('reais') (hypothetically, p of pegarStringDoArray()), a function that finds inside array. Then it would have _e( "Custa 2.43 %s", _p('reais') ).

My question is the following: I can translate strings that are outside the eco() and if so how?

If I haven’t made myself clear I can better illustrate.

Note: Google does not have everything... search by "php gettext array of strings" only returns comparative speed... "php gettext for common used strings" becomes a single mess.

  • reading my question and to illustrate better, I can change it( "It costs 2.43 %s", _p('real') to _e( "%s: 2.43 %s", _p('Value', 'real') )

  • @Maiconcarraro I don’t think it’s duplicate, it’s just related. The question you pointed out is generic about translation and localization applied to PHP. Already this from here is a specific doubt on the implementation of this.

  • @But in doing so, you voted for the closing. And if you voted to close as a duplicate, I understand it’s because you think this question should be closed because it’s a duplicate, after all that’s what the vote means. If you want the question to remain open and only indicate that there is another related one, just have posted a comment with the link.

  • I don’t quite understand your doubt... Can you explain how you’re doing?

  • @Papacharlie like this: I can implement anyway, but I imagined creating an array $gettext= array('First widely used string', 'Second widely used string')... For instead of using on the echo(), _(), _e()... I can at any time use $gettext['Very first string used']...

  • @Papacharlie this is just an example... I don’t intend to use it that way. Array in this case would be the strings I use too much, such as months' name... Numbers up to 20 in full... got it... if I give _('January') 200 times it’s better to use only one January instead of translating 200 Windows

  • @Papacharlie being so, I did not implement because regardless of the way I use... only comes out on the echo... in sprintf... and I intend to have variables instead of using the echo. My _e() function for example automatically detects sprint %s and others, __e() makes the plural... But I want an array with standard strings to use with %s in _e() and __e(). I think I explained it a little better this time.

  • You could have edited the question with this information to make it more readable. Are you using any FW? It’s Cake?

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.