PHP 8.3.4 Released!

bindtextdomain

(PHP 4, PHP 5, PHP 7, PHP 8)

bindtextdomainUygulama adı için bir yol tanımlar

Açıklama

bindtextdomain(string $uygulama_adı, ?string $dizin): string|false

bindtextdomain() işleve bir uygulama için yol tanımlar.

Bağımsız Değişkenler

uygulama_adı

Gettext iletileri için uygulama veya paket adı.

dizin

Bir dizinin yolu. Boş dizge geçerli dizin demektir. null aktarılırsa geçerli dizin döndürülür.

Dönen Değerler

uygulama_adı için tanımlanan tam dizin yolu, başarısızlık durumunda false döner.

Sürüm Bilgisi

Sürüm: Açıklama
8.0.3 dizin artık null olabiliyor. Evvelce, geçerli dizin döndürülemiyordu.

Örnekler

Örnek 1 - bindtextdomain() örneği

<?php

$domain
= 'myapp';
echo
bindtextdomain($domain, '/usr/share/myapp/locale');

?>

Yukarıdaki örneğin çıktısı:

/usr/share/myapp/locale

Notlar

Bilginize:

The bindtextdomain() bilgisi süreç başınadır, evre başına değil.

add a note

User Contributed Notes 2 notes

up
6
n8klatt
9 years ago
The name of your .mo file must match the $domain, e.g. name your files messages.mo and call bindtextdomain("messages", $directory).
up
4
roel dot vermeulen at gmail dot com
7 years ago
I recommend using absolute paths in the $directory parameter. This caused me several hours to debug as Ajax calls to my localization functions messed up the path. And since no error if thrown if the path in $directory cannot be found, one should check the result always:

<?php
// Imagine the path for this file is "/localization" and your locales are in the "/locale" directory.
$pathToDomain = __DIR__ . "/../locale";
if (
$pathToDomain != bindtextdomain($domain, $pathToDomain)) {
// Error handling.
}
?>
To Top