Translate Fields for Provider Payment

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
RodolfoBiscaino
Posts: 2
Joined: 11 Jun 2023, 13:14

Translate Fields for Provider Payment

Post by RodolfoBiscaino » 18 Jun 2023, 17:31

Hello, I need help.

I'm trying to translate the fields for my new payment provider, but I'm having no success.

I created an array with configs for front-end, following my code:

Code: Select all

private array $feConfig = array(
        'mercadopago.holder' => array(
            'code' => 'mercadopago.holder',
            'internalcode'=> 'ccholder',
            'label'=> 'Credit card owner',
            'type'=> 'string',
            'internaltype'=> 'string',
            'default'=> '',
            'required'=> true
        ),
        'mercadopago.number' => array(
            'code' => 'mercadopago.number',
            'internalcode'=> 'ccnumber',
            'label'=> 'Credit card number',
            'type'=> 'string',
            'internaltype'=> 'string',
            'default'=> '',
            'required'=> true
        ),
        'mercadopago.year' => array(
            'code' => 'mercadopago.year',
            'internalcode'=> 'ccyear',
            'label'=> 'Expiry year',
            'type'=> 'select',
            'internaltype'=> 'integer',
            'default'=> '',
            'required'=> true
        ),
        'mercadopago.month' => array(
            'code' => 'mercadopago.month',
            'internalcode'=> 'ccmonth',
            'label'=> 'Expiry month',
            'type'=> 'select',
            'internaltype'=> 'integer',
            'default'=> array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ),
            'required'=> true
        ),
        'mercadopago.cvv' => array(
            'code' => 'mercadopago.cvv',
            'internalcode'=> 'cccvv',
            'label'=> 'CVC code',
            'type'=> 'string',
            'internaltype'=> 'string',
            'default'=> '',
            'required'=> true
        ),
    );
But I can't use these commands phing -f phing.xml i18n inside my package, I follow the commands from documentation https://aimeos.org/docs/latest/developer/translations/

Code: Select all

Buildfile: /var/www/html/packages/rodolfo-gateways-pagamento/phing.xml

rodolfo-gateways-pagamento extension > i18n:

     [exec] 
     [exec] Warning: The use statement with non-compound name 'Exception' has no effect in /var/www/html/vendor/wisembly/xgettext/bin/xgettext on line 23
     [exec] 
     [exec] 
     [exec] Warning: Undefined array key "-j" in /var/www/html/vendor/wisembly/xgettext/bin/xgettext on line 44
     [exec] 
     [exec] Call Stack:
     [exec]     0.0003     406800   1. {main}() /var/www/html/vendor/wisembly/xgettext/bin/xgettext:0
     [exec] 
     [exec] 
     [exec] Warning: Undefined array key "-j" in /var/www/html/vendor/wisembly/xgettext/bin/xgettext on line 47
     [exec] 
     [exec] Call Stack:
     [exec]     0.0003     406800   1. {main}() /var/www/html/vendor/wisembly/xgettext/bin/xgettext:0
     [exec] 
     [exec] 
     [exec] Warning: Undefined array key "-f" in /var/www/html/vendor/wisembly/xgettext/bin/xgettext on line 44
     [exec] 
     [exec] Call Stack:
     [exec]     0.0003     406800   1. {main}() /var/www/html/vendor/wisembly/xgettext/bin/xgettext:0
     [exec] 
     [exec] 
     [exec] Warning: Undefined array key "-f" in /var/www/html/vendor/wisembly/xgettext/bin/xgettext on line 47
     [exec] 
     [exec] Call Stack:
     [exec]     0.0003     406800   1. {main}() /var/www/html/vendor/wisembly/xgettext/bin/xgettext:0
     [exec] 
     [exec] 
     [exec] Deprecated: Creation of dynamic property Xgettext\Xgettext::$cli is deprecated in /var/www/html/vendor/wisembly/xgettext/src/Xgettext/Xgettext.php on line 15
     [exec] 
     [exec] Call Stack:
     [exec]     0.0003     406800   1. {main}() /var/www/html/vendor/wisembly/xgettext/bin/xgettext:0
     [exec]     0.0142    3379920   2. Xgettext\Xgettext->__construct($files = [0 => '--no-wrap', 1 => '--add-comments=///', 2 => '--language=PHP', 3 => '--from-code=UTF-8', 4 => '--keyword=sprintf:1', 5 => '--keyword=dt:2,2t', 6 => '--keyword=dn:2,3,4t', 7 => '--keyword=translate:2,2t', 8 => '--keyword=translate:2,3,4t'], $output = 'i18n/rodolfo-gateways-pagamento-custom.pot', $keywords = [0 => '_', 1 => 'gettext', 2 => 'ngettext:1,2'], $parser = 'Javascript', $enc = 'UTF-8', $cli = TRUE) /var/www/html/vendor/wisembly/xgettext/bin/xgettext:62
     [exec] 
     [exec] 
     [exec] Warning: fopen(--no-wrap): Failed to open stream: No such file or directory in /var/www/html/vendor/wisembly/xgettext/src/Xgettext/Parser/AbstractRegexParser.php on line 53
     [exec] 
     [exec] Call Stack:
     [exec]     0.0003     406800   1. {main}() /var/www/html/vendor/wisembly/xgettext/bin/xgettext:0
     [exec]     0.0142    3379920   2. Xgettext\Xgettext->__construct($files = [0 => '--no-wrap', 1 => '--add-comments=///', 2 => '--language=PHP', 3 => '--from-code=UTF-8', 4 => '--keyword=sprintf:1', 5 => '--keyword=dt:2,2t', 6 => '--keyword=dn:2,3,4t', 7 => '--keyword=translate:2,2t', 8 => '--keyword=translate:2,3,4t'], $output = 'i18n/rodolfo-gateways-pagamento-custom.pot', $keywords = [0 => '_', 1 => 'gettext', 2 => 'ngettext:1,2'], $parser = 'Javascript', $enc = 'UTF-8', $cli = TRUE) /var/www/html/vendor/wisembly/xgettext/bin/xgettext:62
     [exec]     0.0145    3424728   3. Xgettext\Parser\AbstractRegexParser->parse($string = ???) /var/www/html/vendor/wisembly/xgettext/src/Xgettext/Xgettext.php:31
     [exec]     0.0145    3424728   4. fopen($filename = '--no-wrap', $mode = 'r') /var/www/html/vendor/wisembly/xgettext/src/Xgettext/Parser/AbstractRegexParser.php:53
     [exec] 
     [exec] 
     [exec] Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given in /var/www/html/vendor/wisembly/xgettext/src/Xgettext/Parser/AbstractRegexParser.php on line 100
     [exec] 
     [exec] TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given in /var/www/html/vendor/wisembly/xgettext/src/Xgettext/Parser/AbstractRegexParser.php on line 100
     [exec] 
     [exec] Call Stack:
     [exec]     0.0003     406800   1. {main}() /var/www/html/vendor/wisembly/xgettext/bin/xgettext:0
     [exec]     0.0142    3379920   2. Xgettext\Xgettext->__construct($files = [0 => '--no-wrap', 1 => '--add-comments=///', 2 => '--language=PHP', 3 => '--from-code=UTF-8', 4 => '--keyword=sprintf:1', 5 => '--keyword=dt:2,2t', 6 => '--keyword=dn:2,3,4t', 7 => '--keyword=translate:2,2t', 8 => '--keyword=translate:2,3,4t'], $output = 'i18n/rodolfo-gateways-pagamento-custom.pot', $keywords = [0 => '_', 1 => 'gettext', 2 => 'ngettext:1,2'], $parser = 'Javascript', $enc = 'UTF-8', $cli = TRUE) /var/www/html/vendor/wisembly/xgettext/bin/xgettext:62
     [exec]     0.0145    3424728   3. Xgettext\Parser\AbstractRegexParser->parse($string = ???) /var/www/html/vendor/wisembly/xgettext/src/Xgettext/Xgettext.php:31
     [exec]     0.0145    3424848   4. fclose($stream = FALSE) /var/www/html/vendor/wisembly/xgettext/src/Xgettext/Parser/AbstractRegexParser.php:100
     [exec] 

BUILD FAILED
/var/www/html/packages/rodolfo-gateways-pagamento/phing.xml:34:40: Task exited with code 255

Total time: 0.0668 seconds
I already installed the packages phing and xgettext.

Please someone help me.

kdim95
Advanced
Posts: 208
Joined: 26 Aug 2022, 12:17

Re: Translate Fields for Provider Payment

Post by kdim95 » 20 Jun 2023, 09:55

Hello,

I'm not familiar with the error you are experiencing.

Aimeos admins should help you for what you're trying to do but...

If you want to get your translation working sooner, I can tell you how I'm doing the translations a different way.

I use poedit + a text redactor to edit the .po file (for adding new translations).

When the .po file is saved in poedit, it generates a .mo file, you have to remove the .mo extension from that file and replace the current translation file you have in your i18n directory in your extension.

If your translation does not work after uploading the updated translation file, you should check the config in the file manifest.php in your extension. The path to the config you're looking for is 'i18n' inside manifest.php.

The format of the manifest config is the following:

Code: Select all

return [
    ...
    'i18n' => [
        '<DOMAIN>' => '<DIRECTORY IN YOUR EXTENSION>'
    ],
    ...
];
I hope this helps

User avatar
aimeos
Administrator
Posts: 7918
Joined: 01 Jan 1970, 00:00

Re: Translate Fields for Provider Payment

Post by aimeos » 21 Jun 2023, 14:21

You can translate codes of your (payment) sevice provider here:
https://github.com/aimeos/ai-client-htm ... dy.php#L91

The translation in your ./config/shop.php for e.g. English and Portuguese would be:

Code: Select all

'i18n' => [
	'en' => [
		'client/code' => [
			'mercadopago.holder' => ['Card holder']
		]
	],
	'pt' => [
		'client/code' => [
			'mercadopago.holder' => ['porta-cartões']
		]
	]
],
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
RodolfoBiscaino
Posts: 2
Joined: 11 Jun 2023, 13:14

Re: Translate Fields for Provider Payment

Post by RodolfoBiscaino » 22 Jun 2023, 13:25

Hey guys,

Thanks for the answer, but I solved it by running the following code:
In my i18n directory

Code: Select all

msgfmt --statistics -c -o en en.po

Post Reply