Skip to content
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

PoLoader Help #245

Closed
Stephirio opened this issue Dec 10, 2019 · 2 comments
Closed

PoLoader Help #245

Stephirio opened this issue Dec 10, 2019 · 2 comments

Comments

@Stephirio
Copy link

Stephirio commented Dec 10, 2019

From this code:

require_once __DIR__ . "/vendor/autoload.php";

use Gettext\Loader\PoLoader;

$loader = new PoLoader();

$dir = "/app/";

$t = $loader->loadFile($dir . "languages/fr.po");

How can I get a translation (for example "Hi") from the $t variable?
Can i register ($t->register) it or is no longer available?

$t returns me this:

Gettext\Translation Object ( [id:protected] => �Hi [context:protected] => [original:protected] => Hi [plural:protected] => [translation:protected] => Salut [pluralTranslations:protected] => Array ( ) [disabled:protected] => [references:protected] => Gettext\References Object ( ) [flags:protected] => Gettext\Flags Object ( ) [comments:protected] => Gettext\Comments Object ( ) [extractedComments:protected] => Gettext\Comments Object ( ) )

@oscarotero
Copy link
Member

oscarotero commented Dec 10, 2019

The register function is not longer available.

To use the translations in your code, you need to install gettext/translator: https://github.com/php-gettext/Translator

Similar question here: #240

If you only want to find a translation, other way is using the function find:

$text = $t->find(null, 'Hi');

echo $text->getTranslation();

@Stephirio
Copy link
Author

The register function is not longer available.

To use the translations in your code, you need to install gettext/translator: https://github.com/php-gettext/Translator

Similar question here: #240

If you only want to find a translation, other way is using the function find:

$text = $t->find(null, 'Hi');

echo $text->getTranslation();

Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants