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

Incorrect Gettext::exists logic #11310

Closed
sergeyklay opened this issue Jan 15, 2016 · 2 comments
Closed

Incorrect Gettext::exists logic #11310

sergeyklay opened this issue Jan 15, 2016 · 2 comments
Labels
bug A bug report status: medium Medium

Comments

@sergeyklay
Copy link
Contributor

I found a logical bug in the Gettext Adapter by conducting a small test.
The translation db example

How to reproduce.

        $t = new \Phalcon\Translate\Adapter\Gettext(
            [
                'locale'    => 'en_US.utf8',
                'directory' => 'path/to/translation/gettext'
            ]
        );

Actual

       var_dump($t->exists('AAA-BBB-CCCCC')); // bool(true)

Expected

       var_dump($t->exists('AAA-BBB-CCCCC')); // bool(false)

po-file

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# ZhuZongXin <[email protected]>, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: phalcon\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-05-17 13:45+0800\n"
"PO-Revision-Date: 2014-05-17 16:11+0800\n"
"Last-Translator: ZhuZongXin <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 1.6.5\n"
"X-Poedit-SourceCharset: UTF-8\n"

msgid "你好!"
msgstr "Hello!"

msgid "你好 %name%!"
msgstr "Hello %name%!"
@Jurigag
Copy link
Contributor

Jurigag commented Jan 15, 2016

Well from php manual:

gettext() function:

Returns a translated string if one is found in the translation table, or the submitted message if not found.

https://github.com/php/php-src/blob/master/ext/gettext/gettext.c#L187

@sergeyklay
Copy link
Contributor Author

Fixed in 2.0.x

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

3 participants