php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
690 stars 135 forks source link

Native (GettextTranslator) translator does not work with php 5.5 #107

Closed tarampampam closed 8 years ago

tarampampam commented 8 years ago

Hi guys.

I have one problem with your project and php ver. 5.5. When i used 5.3 or 5.4 - all works fine, but when i updated php to 5.5 - native translator (class GettextTranslator, vendor\gettext\gettext\src\GettextTranslator.php) stop working for me. If i use php Translator (vendor\gettext\gettext\src\Translator.php) - all is ok again, but i need exactly in native translator.

Test string:

Original string: Контакты
Translated string (en): Contacts
Translated string (de): Kontakte

Files structure:

index.php
data
  \- locales
     \- de
        \- LC_MESSAGES
           |- messages.mo
           \- messages.po
     \- en
        \- LC_MESSAGES
           |- messages.mo
           \- messages.po

Test code:

$translator = new \Gettext\GettextTranslator();
$translator->setLanguage('de')->loadDomain(
  'messages',
  'data/locales'
);
die($translator->gettext('Контакты'));

First test:

$ php -v
PHP 5.4.45 (cli) (built: Sep  2 2015 23:48:30)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

Output:

Kontakte

All is ok. Second test:

$ php -v
PHP 5.5.33 (cli) (built: Mar  2 2016 15:19:21)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

Output:

Контакты

My string is not translated. Test code was not changed.

Gettext installed by composer and source has no any changes by me:

{
  "require": {
    "php": ">=5.5",
    "gettext/gettext": "3.*@dev",
  },
}

Server software:

Can you fix this or say me how can i do it?

oscarotero commented 8 years ago

I have php5.5 with native gettext working without problems in Ubuntu, so maybe there's a problem with your configuration. To be sure, can you try to use the php functions instead this library?

tarampampam commented 8 years ago

Native PHP gettext not working too. So, this is not your mistake, and here is my server configs:

PHP-5.5.ini ``` ini [PHP] ;user_ini.filename = ".user.ini" ;user_ini.filename = ;user_ini.cache_ttl = 300 engine = On short_open_tag = On asp_tags = Off precision = 14 output_buffering = off ;output_handler = zlib.output_compression = Off ;zlib.output_compression_level = -1 ;zlib.output_handler = implicit_flush = Off unserialize_callback_func = serialize_precision = 17 ; -------------------------------------------- ; Установка защиты от внешнего доступа ; См. Руководство Пользователя: Защита сервера ; -------------------------------------------- %disallow%open_basedir = "%ssitedir%;%sprogdir%/userdata/temp;%sprogdir%/modules/system/html/openserver;%sprogdir%/modules/php/%phpdriver%" %disallow%disable_functions = exec,system,shell_exec,passthru,popen,pclose,dl,apache_note,apache_setenv,define_syslog_variables,pcntl_exec,syslog,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,apache_child_terminate,posix_getpwuid ; -------------------------------------------- disable_classes = ;highlight.string = #DD0000 ;highlight.comment = #FF9900 ;highlight.keyword = #007700 ;highlight.default = #0000BB ;highlight.html = #000000 ignore_user_abort = Off realpath_cache_size=2048k realpath_cache_ttl=600 zend.enable_gc = On ;zend.multibyte = Off ;zend.script_encoding = expose_php = Off max_execution_time = 180 max_input_time = 180 ;max_input_nesting_level = 64 ; max_input_vars = 1000 memory_limit = 1536M ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error handling and logging ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0) ; E_ERROR - fatal run-time errors ; E_RECOVERABLE_ERROR - almost fatal run-time errors ; E_WARNING - run-time warnings (non-fatal errors) ; E_PARSE - compile-time parse errors ; E_NOTICE - run-time notices (these are warnings which often result ; from a bug in your code, but it's possible that it was ; intentional (e.g., using an uninitialized variable and ; relying on the fact it's automatically initialized to an ; empty string) ; E_STRICT - run-time notices, enable to have PHP suggest changes ; to your code which will ensure the best interoperability ; and forward compatibility of your code ; E_CORE_ERROR - fatal errors that occur during PHP's initial startup ; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's ; initial startup ; E_COMPILE_ERROR - fatal compile-time errors ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) ; E_USER_ERROR - user-generated error message ; E_USER_WARNING - user-generated warning message ; E_USER_NOTICE - user-generated notice message ; E_DEPRECATED - warn about code that will not work in future versions ; of PHP ; E_USER_DEPRECATED - user-generated deprecation warnings ; ; Common Values: ; E_ALL (Show all errors, warnings and notices including coding standards.) ; E_ALL & ~E_NOTICE (Show all errors, except for notices) ; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.) ; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT ; http://php.net/error-reporting error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT display_errors = On display_startup_errors = On log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = Off ;report_zend_debug = 0 track_errors = On ;xmlrpc_errors = 0 ;xmlrpc_error_number = 0 html_errors = On ;docref_root = "/phpmanual/" ;docref_ext = .html ;error_prepend_string = "" ;error_append_string = "" error_log = "%sprogdir%/userdata/logs/%phpdriver%_error.log" ;windows.show_crt_warning ;arg_separator.output = "&" ;arg_separator.input = ";&" variables_order = "GPCS" request_order = "GP" register_argc_argv = On auto_globals_jit = On ;enable_post_data_reading = Off auto_prepend_file = auto_append_file = default_mimetype = "text/html" ;default_charset = "UTF-8" ;always_populate_raw_post_data = On include_path = ".;%sprogdir%/modules/php/%phpdriver%;%sprogdir%/modules/php/%phpdriver%/PEAR/pear" doc_root = user_dir = extension_dir = "%sprogdir%/modules/php/%phpdriver%/ext/" enable_dl = Off cgi.force_redirect = 0 cgi.fix_pathinfo=0 fastcgi.impersonate = 0 fastcgi.logging = 0 cgi.nph = 0 cgi.rfc2616_headers = 0 file_uploads = On upload_tmp_dir = "%sprogdir%/userdata/temp/" upload_max_filesize = 100M post_max_size = 100M max_file_uploads = 20 allow_url_fopen = On allow_url_include = Off ;from="john@doe.com" ;user_agent="PHP" default_socket_timeout = 60 ;auto_detect_line_endings = Off extension=php_mbstring.dll extension=php_bz2.dll ;extension=php_com_dotnet.dll extension=php_curl.dll ;extension=php_enchant.dll extension=php_exif.dll extension=php_fileinfo.dll extension=php_gd2.dll extension=php_gettext.dll ;extension=php_gmp.dll extension=php_igbinary.dll extension=php_imagick.dll extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_intl.dll ;extension=php_ldap.dll extension=php_memcache.dll extension=php_mongo.dll extension=php_mongodb.dll extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8.dll ;extension=php_oci8_11g.dll extension=php_openssl.dll extension=php_pdflib.dll ;extension=php_pdo_firebird.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_odbc.dll extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_phalcon.dll extension=php_redis.dll ;extension=php_shmop.dll ; The MIBS data available in the PHP distribution must be installed. ; See http://www.php.net/manual/en/snmp.installation.php ;extension=php_snmp.dll extension=php_soap.dll extension=php_sockets.dll extension=php_sqlite3.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll extension=php_timezonedb.dll extension=php_xmlrpc.dll extension=php_xsl.dll [CLI Server] cli_server.color = On [curl] curl.cainfo = "%sprogdir%/modules/php/%phpdriver%/cacert.pem" [Date] date.timezone = "Europe/Moscow" ;date.default_latitude = 31.7667 ;date.default_longitude = 35.2333 ;date.sunrise_zenith = 90.583333 ;date.sunset_zenith = 90.583333 [filter] ;filter.default = unsafe_raw ;filter.default_flags = [iconv] ;iconv.input_encoding = ISO-8859-1 ;iconv.internal_encoding = ISO-8859-1 ;iconv.output_encoding = ISO-8859-1 [intl] ;intl.default_locale = ;intl.error_level = E_WARNING [sqlite] ;sqlite.assoc_case = 0 [sqlite3] ;sqlite3.extension_dir = [Pcre] ;pcre.backtrack_limit=100000 ;pcre.recursion_limit=100000 [Pdo] ;pdo_odbc.connection_pooling=strict ;pdo_odbc.db2_instance_name [Pdo_mysql] pdo_mysql.cache_size = 2000 pdo_mysql.default_socket= [Phar] ;phar.readonly = On ;phar.require_hash = On ;phar.cache_list = [mail function] ;SMTP = localhost ;smtp_port = 25 ;sendmail_from = me@example.com sendmail_path = "%mailway%" ;mail.force_extra_parameters = mail.add_x_header = On ;mail.log = [SQL] sql.safe_mode = Off [ODBC] ;odbc.default_db = Not yet implemented ;odbc.default_user = Not yet implemented ;odbc.default_pw = Not yet implemented ;odbc.default_cursortype odbc.allow_persistent = On odbc.check_persistent = On odbc.max_persistent = -1 odbc.max_links = -1 odbc.defaultlrl = 4096 odbc.defaultbinmode = 1 ;birdstep.max_links = -1 [Interbase] ibase.allow_persistent = 1 ibase.max_persistent = -1 ibase.max_links = -1 ;ibase.default_db = ;ibase.default_user = ;ibase.default_password = ;ibase.default_charset = ibase.timestampformat = "%Y-%m-%d %H:%M:%S" ibase.dateformat = "%Y-%m-%d" ibase.timeformat = "%H:%M:%S" [MySQL] mysql.allow_local_infile = On mysql.allow_persistent = On mysql.cache_size = 2000 mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = %mysqlport% mysql.default_socket = mysql.default_host = mysql.default_user = mysql.default_password = mysql.connect_timeout = 60 mysql.trace_mode = Off [MySQLi] mysqli.max_persistent = -1 ;mysqli.allow_local_infile = On mysqli.allow_persistent = On mysqli.max_links = -1 mysqli.cache_size = 2000 mysqli.default_port = %mysqlport% mysqli.default_socket = mysqli.default_host = mysqli.default_user = mysqli.default_pw = mysqli.reconnect = Off [mysqlnd] mysqlnd.collect_statistics = On mysqlnd.collect_memory_statistics = On ;mysqlnd.net_cmd_buffer_size = 2048 ;mysqlnd.net_read_buffer_size = 32768 [OCI8] ;oci8.privileged_connect = Off ;oci8.max_persistent = -1 ;oci8.persistent_timeout = -1 ;oci8.ping_interval = 60 ;oci8.connection_class = ;oci8.events = Off ;oci8.statement_cache_size = 20 ;oci8.default_prefetch = 100 ;oci8.old_oci_close_semantics = Off [PostgreSQL] pgsql.allow_persistent = On pgsql.auto_reset_persistent = Off pgsql.max_persistent = -1 pgsql.max_links = -1 pgsql.ignore_notice = 0 pgsql.log_notice = 0 [Sybase-CT] sybct.allow_persistent = On sybct.max_persistent = -1 sybct.max_links = -1 sybct.min_server_severity = 10 sybct.min_client_severity = 10 ;sybct.timeout= ;sybct.packet_size ;sybct.login_timeout= ;sybct.hostname= ;sybct.deadlock_retry_count= [bcmath] bcmath.scale = 0 [browscap] ;browscap = "%sprogdir%/modules/php/%phpdriver%/browscap.ini" [Session] session.save_handler = files session.save_path = "%sprogdir%/userdata/temp/" session.use_cookies = 1 ;session.cookie_secure = session.use_only_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.cookie_httponly = session.serialize_handler = php session.gc_probability = 1 session.gc_divisor = 1000 session.gc_maxlifetime = 1440 session.bug_compat_42 = On session.bug_compat_warn = On session.referer_check = ;session.entropy_length = 32 ;session.entropy_file = /dev/urandom session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 session.hash_function = 0 session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" ;session.upload_progress.enabled = On ;session.upload_progress.cleanup = On ;session.upload_progress.prefix = "upload_progress_" ;session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS" ;session.upload_progress.freq = "1%" ;session.upload_progress.min_freq = "1" [MSSQL] mssql.allow_persistent = On mssql.max_persistent = -1 mssql.max_links = -1 mssql.min_error_severity = 10 mssql.min_message_severity = 10 mssql.compatability_mode = Off ;mssql.connect_timeout = 5 ;mssql.timeout = 60 ;mssql.textlimit = 4096 ;mssql.textsize = 4096 ;mssql.batchsize = 0 ;mssql.datetimeconvert = On mssql.secure_connection = Off ;mssql.max_procs = -1 ;mssql.charset = "ISO-8859-1" [Assertion] ;assert.active = On ;assert.warning = On ;assert.bail = Off ;assert.callback = 0 ;assert.quiet_eval = 0 [COM] ;com.typelib_file = ;com.allow_dcom = true ;com.autoregister_typelib = true ;com.autoregister_casesensitive = false ;com.autoregister_verbose = true ;com.code_page= [mbstring] ;mbstring.language = Japanese ;mbstring.internal_encoding = EUC-JP ;mbstring.http_input = auto ;mbstring.http_output = SJIS ;mbstring.encoding_translation = Off ;mbstring.detect_order = auto ;mbstring.substitute_character = none; ;mbstring.func_overload = 0 ;mbstring.strict_detection = Off ;mbstring.http_output_conv_mimetype= [gd] gd.jpeg_ignore_warning = 1 [exif] ;exif.encode_unicode = ISO-8859-15 ;exif.decode_unicode_motorola = UCS-2BE ;exif.decode_unicode_intel = UCS-2LE ;exif.encode_jis = ;exif.decode_jis_motorola = JIS ;exif.decode_jis_intel = JIS [Tidy] ;tidy.default_config = /usr/local/lib/php/default.tcfg tidy.clean_output = Off [soap] soap.wsdl_cache_enabled=1 soap.wsdl_cache_dir="%sprogdir%/userdata/temp" soap.wsdl_cache_ttl=86400 soap.wsdl_cache_limit = 5 [sysvshm] ;sysvshm.init_mem = 10000 [ldap] ldap.max_links = -1 [mcrypt] ;mcrypt.algorithms_dir= ;mcrypt.modes_dir= [dba] ;dba.default_handler= [Ioncube Loader] ;zend_extension="%sprogdir%/modules/php/%phpdriver%/ext/php_ioncube.dll" [opcache] ;zend_extension="%sprogdir%/modules/php/%phpdriver%/ext/php_opcache.dll" ;opcache.enable=1 ;opcache.enable_cli=0 ;opcache.memory_consumption=64 ;opcache.interned_strings_buffer=4 ;opcache.max_accelerated_files=2000 ;opcache.max_wasted_percentage=5 ;opcache.use_cwd=1 ;opcache.validate_timestamps=1 ;opcache.revalidate_freq=2 ;opcache.revalidate_path=0 ;opcache.save_comments=0 ;opcache.load_comments=0 ;opcache.fast_shutdown=0 ;opcache.enable_file_override=0 ;opcache.optimization_level=0xffffffff ;opcache.inherited_hack=1 ;opcache.dups_fix=0 ;;opcache.blacklist_filename= ;opcache.max_file_size=0 ;opcache.consistency_checks=0 ;opcache.force_restart_timeout=180 ;;opcache.error_log= ;opcache.log_verbosity_level=1 ;;opcache.preferred_memory_model= ;opcache.protect_memory=1 [Xdebug] ;zend_extension="%sprogdir%/modules/php/%phpdriver%/ext/php_xdebug.dll" ;xdebug.default_enable = 1 xdebug.auto_trace = 0 xdebug.collect_includes = 1 ;xdebug.collect_params = 4 ;xdebug.collect_return = 1 ;xdebug.collect_assignments = 1 ;xdebug.collect_vars = 1 xdebug.dump.REQUEST = * xdebug.dump.SESSION = * xdebug.dump.SERVER = REMOTE_ADDR,REQUEST_METHOD ;xdebug.dump.COOKIE = ;xdebug.dump.FILES = ;xdebug.dump.GET = ;xdebug.dump.POST = xdebug.dump_globals = 1 xdebug.dump_once = 1 xdebug.dump_undefined = 1 xdebug.extended_info = 1 ;xdebug.file_link_format = "" ;xdebug.idekey = "" ;xdebug.manual_url = "http://www.php.net" xdebug.max_nesting_level = 256 xdebug.overload_var_dump = 1 ;xdebug.profiler_append = 1 xdebug.profiler_enable = 0 xdebug.profiler_enable_trigger = 0 xdebug.profiler_output_dir="%sprogdir%/userdata/temp/xdebug/" xdebug.profiler_output_name = "cachegrind.out.%H%R" ;xdebug.remote_autostart = 0 ;xdebug.remote_enable = 1 ;xdebug.remote_handler = "dbgp" ;xdebug.remote_host = "localhost" ;xdebug.remote_log = "none" ;xdebug.remote_mode = "req" ;xdebug.remote_port = 9000 ;xdebug.scream = 1 ;xdebug.show_exception_trace = 0 ;xdebug.show_local_vars = 1 ;xdebug.show_mem_delta = 1 ;xdebug.trace_format = 1 ;xdebug.trace_options = 1 xdebug.trace_output_dir = "%sprogdir%/userdata/temp/xdebug/" ;xdebug.trace_output_name = "trace.%H%R" xdebug.var_display_max_children = 256 ;xdebug.var_display_max_data = 1024 xdebug.var_display_max_depth = 16 ;xdebug.remote_cookie_expire_time = 3600 ```
Apache-2.4.ini ``` ini #-----------------------------------------------# # Основная конфигурация сервера #-----------------------------------------------# %httpcharset% AcceptFilter http none AcceptFilter https none AccessFileName .htaccess DocumentRoot "%ssitedir%/" EnableMMAP Off EnableSendfile Off ExtendedStatus On HostnameLookups Off KeepAlive On KeepAliveTimeout 10 Listen %ip%:%httpport% Listen %ip%:%httpsport% MaxConnectionsPerChild %maxrequests% MaxKeepAliveRequests 100 MaxRanges 200 PidFile "%sprogdir%/userdata/temp/httpd.pid" ScriptInterpreterSource script ServerName %ips% ServerRoot "%sprogdir%/modules/http/%httpdriver%" ServerSignature Off ServerTokens Prod ListenBacklog 1024 ThreadLimit 32 ThreadsPerChild 32 ThreadStackSize 8388608 Timeout 30 UseCanonicalName Off #-----------------------------------------------# # Подключение модулей #-----------------------------------------------# LoadModule access_compat_module modules/mod_access_compat.so LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule allowmethods_module modules/mod_allowmethods.so LoadModule asis_module modules/mod_asis.so LoadModule auth_basic_module modules/mod_auth_basic.so #LoadModule auth_digest_module modules/mod_auth_digest.so #LoadModule authn_anon_module modules/mod_authn_anon.so LoadModule authn_core_module modules/mod_authn_core.so #LoadModule authn_dbd_module modules/mod_authn_dbd.so #LoadModule authn_dbm_module modules/mod_authn_dbm.so LoadModule authn_file_module modules/mod_authn_file.so #LoadModule authn_socache_module modules/mod_authn_socache.so #LoadModule authnz_ldap_module modules/mod_authnz_ldap.so LoadModule authz_core_module modules/mod_authz_core.so #LoadModule authz_dbd_module modules/mod_authz_dbd.so #LoadModule authz_dbm_module modules/mod_authz_dbm.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_host_module modules/mod_authz_host.so #LoadModule authz_owner_module modules/mod_authz_owner.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule autoindex_module modules/mod_autoindex.so #LoadModule buffer_module modules/mod_buffer.so #LoadModule cache_module modules/mod_cache.so #LoadModule cache_disk_module modules/mod_cache_disk.so #LoadModule cern_meta_module modules/mod_cern_meta.so LoadModule cgi_module modules/mod_cgi.so #LoadModule charset_lite_module modules/mod_charset_lite.so #LoadModule data_module modules/mod_data.so #LoadModule dav_module modules/mod_dav.so #LoadModule dav_fs_module modules/mod_dav_fs.so #LoadModule dav_lock_module modules/mod_dav_lock.so #LoadModule dbd_module modules/mod_dbd.so #LoadModule deflate_module modules/mod_deflate.so LoadModule dir_module modules/mod_dir.so #LoadModule dumpio_module modules/mod_dumpio.so LoadModule env_module modules/mod_env.so #LoadModule expires_module modules/mod_expires.so #LoadModule ext_filter_module modules/mod_ext_filter.so #LoadModule file_cache_module modules/mod_file_cache.so #LoadModule filter_module modules/mod_filter.so LoadModule headers_module modules/mod_headers.so #LoadModule heartbeat_module modules/mod_heartbeat.so #LoadModule heartmonitor_module modules/mod_heartmonitor.so #LoadModule ident_module modules/mod_ident.so #LoadModule imagemap_module modules/mod_imagemap.so LoadModule include_module modules/mod_include.so #LoadModule info_module modules/mod_info.so LoadModule isapi_module modules/mod_isapi.so #LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so #LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so #LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so #LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so #LoadModule ldap_module modules/mod_ldap.so #LoadModule logio_module modules/mod_logio.so LoadModule log_config_module modules/mod_log_config.so #LoadModule log_debug_module modules/mod_log_debug.so #LoadModule log_forensic_module modules/mod_log_forensic.so #LoadModule lua_module modules/mod_lua.so LoadModule mime_module modules/mod_mime.so #LoadModule mime_magic_module modules/mod_mime_magic.so LoadModule negotiation_module modules/mod_negotiation.so #LoadModule proxy_module modules/mod_proxy.so #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so #LoadModule proxy_connect_module modules/mod_proxy_connect.so #LoadModule proxy_express_module modules/mod_proxy_express.so #LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so #LoadModule proxy_html_module modules/mod_proxy_html.so #LoadModule proxy_http_module modules/mod_proxy_http.so #LoadModule proxy_scgi_module modules/mod_proxy_scgi.so #LoadModule ratelimit_module modules/mod_ratelimit.so #LoadModule reflector_module modules/mod_reflector.so #LoadModule remoteip_module modules/mod_remoteip.so #LoadModule request_module modules/mod_request.so #LoadModule reqtimeout_module modules/mod_reqtimeout.so LoadModule rewrite_module modules/mod_rewrite.so #LoadModule sed_module modules/mod_sed.so #LoadModule session_module modules/mod_session.so #LoadModule session_cookie_module modules/mod_session_cookie.so #LoadModule session_crypto_module modules/mod_session_crypto.so #LoadModule session_dbd_module modules/mod_session_dbd.so LoadModule setenvif_module modules/mod_setenvif.so #LoadModule slotmem_plain_module modules/mod_slotmem_plain.so #LoadModule slotmem_shm_module modules/mod_slotmem_shm.so #LoadModule socache_dbm_module modules/mod_socache_dbm.so #LoadModule socache_memcache_module modules/mod_socache_memcache.so LoadModule socache_shmcb_module modules/mod_socache_shmcb.so #LoadModule speling_module modules/mod_speling.so LoadModule ssl_module modules/mod_ssl.so LoadModule status_module modules/mod_status.so #LoadModule substitute_module modules/mod_substitute.so #LoadModule unique_id_module modules/mod_unique_id.so #LoadModule userdir_module modules/mod_userdir.so #LoadModule usertrack_module modules/mod_usertrack.so #LoadModule version_module modules/mod_version.so #LoadModule vhost_alias_module modules/mod_vhost_alias.so #LoadModule watchdog_module modules/mod_watchdog.so #LoadModule xml2enc_module modules/mod_xml2enc.so PHPINIDir "%sprogdir%/modules/php/%phpdriver%" LoadModule php5_module "%sprogdir%/modules/php/%phpdriver%/php5apache2_4.dll" RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500 #-----------------------------------------------# # Настройка прав доступа к серверу #-----------------------------------------------# AllowOverride All Options -MultiViews -Indexes +FollowSymLinks -IncludesNoExec -Includes -ExecCGI Require all denied AllowOverride All Options -MultiViews +Indexes +FollowSymLinks +IncludesNoExec +Includes +ExecCGI #Options +FollowSymLinks +SymLinksIfOwnerMatch # Защита лучше, но нагрузка выше Require all granted AllowOverride All Options -MultiViews -Indexes +FollowSymLinks -IncludesNoExec -Includes -ExecCGI AddDefaultCharset Off Require all denied Require ip 127.0.0.0/8 ::1/128 Require ip %ips% %allow%Require all granted AllowOverride All Options -MultiViews -Indexes +FollowSymLinks -IncludesNoExec -Includes -ExecCGI AddDefaultCharset Off DirectoryIndex index.html Require all granted Alias /openserver/ "%sprogdir%/modules/system/html/openserver/" AllowOverride All Options +ExecCGI Require all granted Require all denied Require all denied #-----------------------------------------------# # Конфигурация сообщений об ошибках #-----------------------------------------------# ErrorLog "%sprogdir%/userdata/logs/%httpdriver%_errora.log" LogLevel warn BufferedLogs Off LogFormat "%v: %a %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%v: %a %t \"%r\" %>s %b" common LogFormat "%v: %a %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio %log%CustomLog "%sprogdir%/userdata/logs/%httpdriver%_queriesa.log" combined #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html #ErrorDocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument 402 http://ret.ru/subscription_info.html Alias /apacheerror/ "%sprogdir%/modules/http/%httpdriver%/error/" AllowOverride All Options IncludesNoExec AddOutputFilter Includes html AddHandler type-map var Require all granted LanguagePriority en cs de es fr it ja ko nl pl pt-br ro sv tr ForceLanguagePriority Prefer Fallback ErrorDocument 400 /apacheerror/HTTP_BAD_REQUEST.html.var ErrorDocument 401 /apacheerror/HTTP_UNAUTHORIZED.html.var ErrorDocument 403 /apacheerror/HTTP_FORBIDDEN.html.var ErrorDocument 404 /apacheerror/HTTP_NOT_FOUND.html.var ErrorDocument 405 /apacheerror/HTTP_METHOD_NOT_ALLOWED.html.var ErrorDocument 408 /apacheerror/HTTP_REQUEST_TIME_OUT.html.var ErrorDocument 410 /apacheerror/HTTP_GONE.html.var ErrorDocument 411 /apacheerror/HTTP_LENGTH_REQUIRED.html.var ErrorDocument 412 /apacheerror/HTTP_PRECONDITION_FAILED.html.var ErrorDocument 413 /apacheerror/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var ErrorDocument 414 /apacheerror/HTTP_REQUEST_URI_TOO_LARGE.html.var ErrorDocument 415 /apacheerror/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var ErrorDocument 500 /apacheerror/HTTP_INTERNAL_SERVER_ERROR.html.var ErrorDocument 501 /apacheerror/HTTP_NOT_IMPLEMENTED.html.var ErrorDocument 502 /apacheerror/HTTP_BAD_GATEWAY.html.var ErrorDocument 503 /apacheerror/HTTP_SERVICE_UNAVAILABLE.html.var ErrorDocument 506 /apacheerror/HTTP_VARIANT_ALSO_VARIES.html.var #-----------------------------------------------# # Конфигурация MIME #-----------------------------------------------# TypesConfig "%sprogdir%/modules/http/%httpdriver%/conf/mime.types" #AddType application/x-gzip .tgz #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType image/x-icon .ico AddHandler cgi-script .cgi .pl AddType application/x-httpd-php .php .php5 .phtml #AddHandler type-map var AddType text/html .shtml AddOutputFilter INCLUDES .shtml MIMEMagicFile "%sprogdir%/modules/http/%httpdriver%/conf/magic" #-----------------------------------------------# # Конфигурация Index-а и иконок #-----------------------------------------------# DirectoryIndex index.php index.html index.htm index.pl Alias /apacheicons/ "%sprogdir%/modules/http/%httpdriver%/icons/" Options +Indexes +MultiViews AllowOverride All Require all granted AddIconByEncoding (CMP,/apacheicons/compressed.gif) x-compress x-gzip AddIconByType (TXT,/apacheicons/text.gif) text/* AddIconByType (IMG,/apacheicons/image2.gif) image/* AddIconByType (SND,/apacheicons/sound2.gif) audio/* AddIconByType (VID,/apacheicons/movie.gif) video/* AddIcon /apacheicons/binary.gif .bin .exe AddIcon /apacheicons/binhex.gif .hqx AddIcon /apacheicons/tar.gif .tar AddIcon /apacheicons/world2.gif .wrl .wrl.gz .vrml .vrm .iv AddIcon /apacheicons/compressed.gif .Z .z .tgz .gz .zip AddIcon /apacheicons/a.gif .ps .ai .eps AddIcon /apacheicons/layout.gif .html .shtml .htm .pdf AddIcon /apacheicons/text.gif .txt AddIcon /apacheicons/c.gif .c AddIcon /apacheicons/p.gif .pl .py AddIcon /apacheicons/f.gif .for AddIcon /apacheicons/dvi.gif .dvi AddIcon /apacheicons/uuencoded.gif .uu AddIcon /apacheicons/script.gif .conf .sh .shar .csh .ksh .tcl AddIcon /apacheicons/tex.gif .tex AddIcon /apacheicons/bomb.gif core AddIcon /apacheicons/back.gif .. AddIcon /apacheicons/hand.right.gif README AddIcon /apacheicons/folder.gif ^^DIRECTORY^^ AddIcon /apacheicons/blank.gif ^^BLANKICON^^ DefaultIcon /apacheicons/unknown.gif #AddDescription "GZIP compressed document" .gz #AddDescription "tar archive" .tar #AddDescription "GZIP compressed tar archive" .tgz ReadmeName README.html HeaderName HEADER.html IndexOptions FancyIndexing HTMLTable VersionSort NameWidth=* IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t #-----------------------------------------------# # Подключение языков и кодировок #-----------------------------------------------# #DefaultLanguage nl AddLanguage ca .ca AddLanguage cs .cz .cs AddLanguage da .dk AddLanguage de .de AddLanguage el .el AddLanguage en .en AddLanguage eo .eo AddLanguage es .es AddLanguage et .et AddLanguage fr .fr AddLanguage he .he AddLanguage hr .hr AddLanguage it .it AddLanguage ja .ja AddLanguage ko .ko AddLanguage ltz .ltz AddLanguage nl .nl AddLanguage nn .nn AddLanguage no .no AddLanguage pl .po AddLanguage pt .pt AddLanguage pt-BR .pt-br AddLanguage ru .ru AddLanguage sv .sv AddLanguage tr .tr AddLanguage zh-CN .zh-cn AddLanguage zh-TW .zh-tw LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv tr zh-CN zh-TW ForceLanguagePriority Prefer Fallback AddCharset us-ascii .ascii .us-ascii AddCharset ISO-8859-1 .iso8859-1 .latin1 AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen AddCharset ISO-8859-3 .iso8859-3 .latin3 AddCharset ISO-8859-4 .iso8859-4 .latin4 AddCharset ISO-8859-5 .iso8859-5 .cyr .iso-ru AddCharset ISO-8859-6 .iso8859-6 .arb .arabic AddCharset ISO-8859-7 .iso8859-7 .grk .greek AddCharset ISO-8859-8 .iso8859-8 .heb .hebrew AddCharset ISO-8859-9 .iso8859-9 .latin5 .trk AddCharset ISO-8859-10 .iso8859-10 .latin6 AddCharset ISO-8859-13 .iso8859-13 AddCharset ISO-8859-14 .iso8859-14 .latin8 AddCharset ISO-8859-15 .iso8859-15 .latin9 AddCharset ISO-8859-16 .iso8859-16 .latin10 AddCharset ISO-2022-JP .iso2022-jp .jis AddCharset ISO-2022-KR .iso2022-kr .kis AddCharset ISO-2022-CN .iso2022-cn .cis AddCharset Big5 .Big5 .big5 .b5 AddCharset cn-Big5 .cn-big5 AddCharset WINDOWS-1251 .cp-1251 .win-1251 AddCharset CP866 .cp866 AddCharset KOI8 .koi8 AddCharset KOI8-E .koi8-e AddCharset KOI8-r .koi8-r .koi8-ru AddCharset KOI8-U .koi8-u AddCharset KOI8-ru .koi8-uk .ua AddCharset ISO-10646-UCS-2 .ucs2 AddCharset ISO-10646-UCS-4 .ucs4 AddCharset UTF-7 .utf7 AddCharset UTF-8 .utf8 AddCharset UTF-16 .utf16 AddCharset UTF-16BE .utf16be AddCharset UTF-16LE .utf16le AddCharset UTF-32 .utf32 AddCharset UTF-32BE .utf32be AddCharset UTF-32LE .utf32le AddCharset euc-cn .euc-cn AddCharset euc-gb .euc-gb AddCharset euc-jp .euc-jp AddCharset euc-kr .euc-kr AddCharset EUC-TW .euc-tw AddCharset gb2312 .gb2312 .gb AddCharset iso-10646-ucs-2 .ucs-2 .iso-10646-ucs-2 AddCharset iso-10646-ucs-4 .ucs-4 .iso-10646-ucs-4 AddCharset shift_jis .shift_jis .sjis #-----------------------------------------------# # Конфигурация SSL #-----------------------------------------------# SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA SSLCompression Off SSLCryptoDevice builtin SSLHonorCipherOrder On Mutex default SSLPassPhraseDialog builtin SSLProtocol ALL -SSLv2 -SSLv3 SSLRandomSeed startup builtin SSLRandomSeed connect builtin SSLSessionCache "shmcb:%sprogdir%/userdata/temp/ssl_scache(512000)" SSLSessionCacheTimeout 300 SSLStrictSNIVHostCheck Off SSLVerifyClient none #-----------------------------------------------# # Исключения User Agent #-----------------------------------------------# BrowserMatch "Mozilla/2" nokeepalive BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0 BrowserMatch "RealPlayer 4\.0" force-response-1.0 BrowserMatch "Java/1\.0" force-response-1.0 BrowserMatch "JDK/1\.0" force-response-1.0 BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully BrowserMatch "MS FrontPage" redirect-carefully BrowserMatch "^WebDrive" redirect-carefully BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully BrowserMatch "^gnome-vfs/1.0" redirect-carefully BrowserMatch "^XML Spy" redirect-carefully BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully #-----------------------------------------------# # Первичный виртуальный хост "по умолчанию" #-----------------------------------------------# DocumentRoot "%sprogdir%/modules/system/html/default" ServerName "default" ServerAlias "default" SetHandler server-status Require all denied Require ip 127.0.0.0/8 ::1/128 Require ip %ips% %allow%Require all granted SetHandler server-info Require all denied Require ip 127.0.0.0/8 ::1/128 Require ip %ips% %allow%Require all granted DocumentRoot "%sprogdir%/modules/system/html/default" ServerName "default" ServerAlias "default" SSLEngine on #Header always set Strict-Transport-Security "max-age=94608000; includeSubDomains; preload" #SSLCACertificateFile "" #SSLCertificateChainFile "" SSLCertificateFile "%sprogdir%/userdata/config/server.crt" SSLCertificateKeyFile "%sprogdir%/userdata/config/server.key" SetEnvIf User-Agent ".*MSIE [1-5].*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 SetEnvIf User-Agent ".*MSIE [6-9].*" \ ssl-unclean-shutdown SSLOptions +StdEnvVars SetHandler server-status Require all denied Require ip 127.0.0.0/8 ::1/128 Require ip %ips% %allow%Require all granted SetHandler server-info Require all denied Require ip 127.0.0.0/8 ::1/128 Require ip %ips% %allow%Require all granted #-----------------------------------------------# # Конец конфигурации хоста "по умолчанию" #-----------------------------------------------# ```

Configs php 5.5 and 5.4 diff

What am I doing wrong?

oscarotero commented 8 years ago

Maybe you don't have the locale installed?

tarampampam commented 8 years ago

ps. I tested with this code:

$language = 'en';
putenv("LANG=$language");
setlocale(LC_ALL, $language);

$domain = 'messages';
bindtextdomain($domain, "data/locales");
textdomain($domain);

echo gettext("Контакты");
tarampampam commented 8 years ago

Installed locale? What do you mean?

oscarotero commented 8 years ago

Native gettext use the locales installed in the operating system. This is why is so hard to use it under some circunstances. If you want to use, for instance the language "es", you have to install the locale in your operating system. Note also that the same locale is called differently in some operating systems (for example "es_ES" instead simply "es"). Here you can see how to configure it in ubuntu: http://stackoverflow.com/questions/5257519/cant-get-gettext-php-on-ubuntu-working I don't know how windows handle this.

tarampampam commented 8 years ago

I dont think what problem in installed locales. When i use php 5.4 or 5.3 - all work fine. Hm.. What the sh*t..

eusonlito commented 8 years ago

If you are using the native translator, you must have the locale installed and you must set the setLanguage with fully system supported language:

sudo locale-gen en_US.UTF-8 de_DE.UTF-8
sudo update-locale
$translator = new \Gettext\GettextTranslator();
$translator->setLanguage('de_DE.UTF-8')->loadDomain(
  'messages',
  'data/locales'
);
die($translator->gettext('Контакты'));

Try!

tarampampam commented 8 years ago

Setting locale like 'de_DE.UTF-8' has no effect

eusonlito commented 8 years ago

My code working, from PHP 5.3 to PHP 7:

$locale = 'es_ES.UTF-8';

defined('LC_MESSAGES') or define('LC_MESSAGES', 5);

putenv('LANG='.$locale);
putenv('LANGUAGE='.$locale);
putenv('LC_MESSAGES='.$locale);
putenv('LC_PAPER='.$locale);
putenv('LC_TIME='.$locale);
putenv('LC_MONETARY='.$locale);

setlocale(LC_MESSAGES, $locale);
setlocale(LC_COLLATE, $locale);
setlocale(LC_TIME, $locale);
setlocale(LC_MONETARY, $locale);

$translator = new GettextTranslator();
$translator->setLanguage($locale);
$translator->loadDomain('messages', 'gettext');

bind_textdomain_codeset('messages', 'UTF-8');

$translator->register();

But only works after install system package languages and reboot apache.

tarampampam commented 8 years ago
    $locale = 'de';

    defined('LC_MESSAGES') or define('LC_MESSAGES', 5);

    putenv('LANG='.$locale);
    putenv('LANGUAGE='.$locale);
    putenv('LC_MESSAGES='.$locale);
    putenv('LC_PAPER='.$locale);
    putenv('LC_TIME='.$locale);
    putenv('LC_MONETARY='.$locale);

    setlocale(LC_MESSAGES, $locale);
    setlocale(LC_COLLATE, $locale);
    setlocale(LC_TIME, $locale);
    setlocale(LC_MONETARY, $locale);

    $translator = new \Gettext\GettextTranslator();
    $translator->setLanguage($locale)->loadDomain(
      'messages',
      'data/locales'
    );
    die($translator->gettext('Контакты'));

Works with php 5.4, and does not works with php 5.5

IDK why.

eusonlito commented 8 years ago

And $locale = 'de_DE.UTF-8';?

tarampampam commented 8 years ago

Yep, i tried. It has no effect too

tarampampam commented 8 years ago

Hm.. Bug #66265 gettext is not working anymore

oscarotero commented 8 years ago

Oops, here's the problem. I think there's nothing that this library can do.

tarampampam commented 8 years ago

Thx for support, guys. There is no way.