-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to print string translation from object created by MO loader #240
Comments
You need install the gettext/translator package to use a translator in your templates. Once it's installed: use Gettext\Translator;
$translator = Translator::createFromTranslations($yourMoTranslations);
echo $translator->gettext('Hello world');
echo $translator->dgettext('textdomain', 'Hello world'); |
So complete code after
will looks like:
Right? Do you think you can add this to the main readme file? |
Can use __(); function in gettext v5? |
Im trying to update version 4.6 to 5.5.1, in 4.6 i was using translations with the gettext extension |
@lavitzz The translator functionality is in a different package: https://github.com/php-gettext/Translator see my previous comments: #240 (comment) |
Ok thx, i try: |
@lavitzz can you share complete-example code? |
@jasomdotnet yes, i use this:
|
I'm sharing my code so far:
|
Hi,
I have been able to load translation.mo with MO loader. Now, how to print translation of string from object created by MO loader, something like:
echo $translations->gettext('Hello world!', 'optional-textdomain');
With my current knowledge I was not able to figure out from documentation. Is it possible?
The text was updated successfully, but these errors were encountered: