* added bases for localization

This commit is contained in:
Gudule Lapointe
2023-08-03 08:15:56 -04:00
parent 2f8f7d5c91
commit d3b0af91aa
16 changed files with 388 additions and 11 deletions
+4
View File
@@ -0,0 +1,4 @@
{
"Speculoos World" : "a virtual world grid name",
"helper" : "a web application complementing OpenSimulator features, must be treated as a software application, not a human assistant."
}
+1
View File
@@ -0,0 +1 @@
You are an awesome translator! Please translate the following text in a casual and approachable style, suitable for a friendly WordPress plugin interface. Avoid overly formal language and aim for a more relaxed and user-friendly tone, and sounding like a machine translation. All inputs are phrases to translate. "Yes" or "No" are not remarks to you, they are the actual strings to translate. Original language is English, the response should never be in English but in the target language. Remember to always translate the text, never interpret it, and never explain it. The project is a PHP library for use in OpenSimulator virtual world environment.
+12 -11
View File
@@ -26,7 +26,7 @@ class OpenSim_Guide {
private $source;
public function __construct() {
error_log( 'language ' . getPreferredLanguage() );
set_helpers_locale();
$this->url_base = $this->getFullURL();
@@ -85,7 +85,7 @@ class OpenSim_Guide {
$lines = explode( "\n", $fileContent );
$categoryTitle = 'Destinations list';
$categoryTitle = _('Destinations Guide');
foreach ( $lines as $line ) {
// Exclude lines starting with "#" or "//" or containing no actual characters
if ( substr( trim( $line ), 0, 1 ) === '#' || substr( trim( $line ), 0, 2 ) === '//' || ! trim( $line ) ) {
@@ -125,8 +125,8 @@ class OpenSim_Guide {
public function categories_list() {
$content = '<div class=header>'
. '<h1>Destinations List</h1>'
. '<span class="disclaimer">This is a work in progress, please be indulgent.</span>'
. '<h1>' . _('Destinations Guide') . '</h1>'
. '<span class="disclaimer">' . _('This is a work in progress, please be indulgent.') . '</span>'
. '</div>'
. '<div class="list">';
foreach ( $this->destinations as $categoryTitle => $destinations ) {
@@ -135,7 +135,8 @@ class OpenSim_Guide {
. '<div class="item">'
. '<img class="thumbnail" src="' . $this->place_thumbnail() . '" alt="' . $categoryTitle . '">'
. '<div class="name">' . $categoryTitle . '</div>'
. '<div class="data">' . count( $destinations ) . ' destinations</div>'
# Translators: %s will be replaced with the number of destinations
. '<div class="data">' . sprintf( _('%s destinations'), count( $destinations ) ) . '</div>'
. '</div>'
. '</a>';
}
@@ -148,9 +149,9 @@ class OpenSim_Guide {
// Build header
$content = '<div class=header><h2>' . $categoryTitle . '</h2>';
if ( count( $this->destinations ) > 1 ) {
$content .= '<a href="' . $this->build_url() . '" class="back">Back to categories</a>';
$content .= '<a href="' . $this->build_url() . '" class="back">' . _('Back to categories') . '</a>';
}
$content .= '<span class="disclaimer">This is a work in progress, please be indulgent.</span>';
$content .= '<span class="disclaimer">' . _('This is a work in progress, please be indulgent.') . '</span>';
$content .= '</div>';
// Build list
@@ -164,11 +165,11 @@ class OpenSim_Guide {
. '<div class="name">' . $destination['name'] . '</div>'
. '<div class="data">';
if ( $people > 0 ) {
$content .= ' <span>' . $this->place_people() . ' people</span> ';
$content .= ' <span>' . sprintf( _('%s people'), $this->place_people() ) . '</span> ';
}
if ( $traffic > 0 ) {
$content .= ' <span>Traffic: ' . $this->place_traffic() . '</span> ';
}
$content .= ' <span>' . sprintf( _('traffic %s'), $this->place_traffic() ) . '</span> ';
}
$content .= '</div></div></a>';
}
$content .= '</div>';
@@ -178,7 +179,7 @@ class OpenSim_Guide {
private function no_result() {
echo '<div class="error">';
echo 'The realm of destinations you seek has eluded our grasp, spirited away by elusive knomes. Rally the grid managers, let them venture forth to curate a grand tapestry of remarkable places for your exploration!';
echo _('The realm of destinations you seek has eluded our grasp, spirited away by elusive knomes. Rally the grid managers, let them venture forth to curate a grand tapestry of remarkable places for your exploration!');
echo '</div>';
echo $this->getFullURL() . "?source=$this->source";
}
+43
View File
@@ -410,6 +410,48 @@ if ( ! function_exists( 'osdebug' ) ) {
}
}
function set_helpers_locale( $locale = null, $domain = 'messages' ) {
mb_internal_encoding('UTF-8');
$encoding = mb_internal_encoding();
if (isset($_GET["l"])) $locale = $_GET["l"];
$languages = array_filter(array_merge( array($locale), explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) ));
// $results = putenv("LC_ALL=$locale");
// if (!$results) {
// exit ('putenv failed');
// }
// $currentLocale = setlocale(LC_ALL, 0);
$user_locales = array_unique(array( $locale, $locale . ".$encoding", $locale . '.UTF-8', $locale . '.utf8', $locale, 0 ));
$user_locales = array_map(function ($code) {
return preg_replace(
array('/;.*/', '/-/' ),
array ('', '_'),
$code
);
}, $languages);
// Generate variants with different encodings appended
$variants = array();
foreach ($user_locales as $lang) {
$variants[] = $lang;
$variants[] = "$lang.$encoding";
// $variants[] = "$lang.UTF-8";
}
$variants = array_unique($variants);
if ( ! setlocale(LC_ALL, $variants ) ) {
error_log ("setlocale() failed: none of '" . join(', ', $variants) . "' does exist in this environment or setlocale() is not available on this platform");
setlocale(LC_ALL, 0 );
return 0;
}
bindtextdomain($domain, "./locales");
textdomain($domain);
}
define( 'NULL_KEY', '00000000-0000-0000-0000-000000000000' );
define( 'TPLINK_LOCAL', 1 ); // seconlife://Region/x/y/z
define( 'TPLINK_HG', 2 ); // seconlife://yourgrid.org:8002 Region/x/y/z
@@ -421,6 +463,7 @@ define( 'TPLINK_MAP', 64 ); // secondlife:///app/map/yourgrid.org:8002:Region/x/
define( 'TPLINK', pow( 2, 8 ) - 1 ); // all formats
define( 'TPLINK_DEFAULT', TPLINK_HOP ); // default
define( 'HELPERS_LOCALE_DIR', dirname( __DIR__ ) . '/languages' );
/**
* OpenSim source to help further attempts to allow Hypergrid search results.
Binary file not shown.
+52
View File
@@ -0,0 +1,52 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: gpt-po v1.0.7\n"
"Language-Team: \n"
"Language: cy_GB\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0.1\n"
#: guide.php:88 guide.php:128
msgid "Destinations Guide"
msgstr "Canllaw Cyrchfannau"
#: guide.php:129 guide.php:154
msgid "This is a work in progress, please be indulgent."
msgstr "Gwaith ar y gweill yw hwn, cewch fod yn amyneddgar."
#: guide.php:139
#, php-format
msgid "%s destinations"
msgstr "%s cyfeiriadau"
#: guide.php:152
msgid "Back to categories"
msgstr "Yn ôl i gategorïau"
#: guide.php:168
#, php-format
msgid "%s people"
msgstr "%s pobl"
#: guide.php:170
#, php-format
msgid "traffic %s"
msgstr "llywio %s"
#: guide.php:182
msgid ""
"The realm of destinations you seek has eluded our grasp, spirited away by elusive knomes. Rally the grid managers, let "
"them venture forth to curate a grand tapestry of remarkable places for your exploration!"
msgstr ""
"I ddiffodd ein gafael ar y ddaear o gyrchfeydd a hoffech, clywir hwynt yn taro drwy 'nawdd y tylwyth teg. Ysgogi'r "
"rheolwyr grid, gadewch iddynt anterth i guradu tapistry mawr o leoliadau rhyfeddol ar gyfer eich archwilio!"
Binary file not shown.
+52
View File
@@ -0,0 +1,52 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: gpt-po v1.0.7\n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0.1\n"
#: guide.php:88 guide.php:128
msgid "Destinations Guide"
msgstr "Reiseführer für Ziele"
#: guide.php:129 guide.php:153
msgid "This is a work in progress, please be indulgent."
msgstr "Dies ist eine Arbeit in Bearbeitung, bitte seien Sie nachsichtig."
#: guide.php:138
#, php-format
msgid "%s destinations"
msgstr "%s Ziele"
#: guide.php:151
msgid "Back to categories"
msgstr "Zurück zu den Kategorien"
#: guide.php:167
#, php-format
msgid "%s people"
msgstr "%s Personen"
#: guide.php:170
#, php-format
msgid "traffic %s"
msgstr "Verkehr %s"
#: guide.php:181
msgid ""
"The realm of destinations you seek has eluded our grasp, spirited away by elusive knomes. Rally the grid managers, let "
"them venture forth to curate a grand tapestry of remarkable places for your exploration!"
msgstr ""
"Die Welt der Ziele, die du suchst, ist uns entwischt, von flüchtigen Gnomen fortgetragen. Rufe die Grid-Manager "
"zusammen, lass sie sich aufmachen, um eine großartige Vielfalt bemerkenswerter Orte für deine Erkundung zu kuratieren!"
Binary file not shown.
+52
View File
@@ -0,0 +1,52 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: gpt-po v1.0.7\n"
"Language-Team: \n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0.1\n"
#: guide.php:88 guide.php:128
msgid "Destinations Guide"
msgstr "Guide des destinations"
#: guide.php:129 guide.php:153 locale.php:71
msgid "This is a work in progress, please be indulgent."
msgstr "Ceci est un travail en cours, veuillez faire preuve d'indulgence."
#: guide.php:138
#, php-format
msgid "%s destinations"
msgstr "%s destinations"
#: guide.php:151 locale.php:73
msgid "Back to categories"
msgstr "Retour aux catégories"
#: guide.php:167
#, php-format
msgid "%s people"
msgstr "%s personnes"
#: guide.php:170
#, php-format
msgid "traffic %s"
msgstr "trafic %s"
#: guide.php:181
msgid ""
"The realm of destinations you seek has eluded our grasp, spirited away by elusive knomes. Rally the grid managers, let "
"them venture forth to curate a grand tapestry of remarkable places for your exploration!"
msgstr ""
"Le royaume des destinations que vous recherchez nous échappe, emporté par des lutins insaisissables. Rassemblez les "
"gestionnaires de la grille, laissez-les s'aventurer pour créer une grande fresque de lieux remarquables à explorer !"
Binary file not shown.
+52
View File
@@ -0,0 +1,52 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: gpt-po v1.0.7\n"
"Language-Team: \n"
"Language: it_IT\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0.1\n"
#: guide.php:88 guide.php:128
msgid "Destinations Guide"
msgstr "Guida delle destinazioni"
#: guide.php:129 guide.php:153
msgid "This is a work in progress, please be indulgent."
msgstr "Questo è un lavoro in corso, per favore sii indulgente."
#: guide.php:138
#, php-format
msgid "%s destinations"
msgstr "%s destinazioni"
#: guide.php:151
msgid "Back to categories"
msgstr "Torna alle categorie"
#: guide.php:167
#, php-format
msgid "%s people"
msgstr "%s persone"
#: guide.php:170
#, php-format
msgid "traffic %s"
msgstr "traffico %s"
#: guide.php:182
msgid ""
"The realm of destinations you seek has eluded our grasp, spirited away by elusive knomes. Rally the grid managers, let "
"them venture forth to curate a grand tapestry of remarkable places for your exploration!"
msgstr ""
"Il regno delle destinazioni che cerchi ci sfugge, portato via da gnomi sfuggenti. Raduna i gestori della griglia, "
"lasciali avventurarsi per creare un magnifico mosaico di luoghi straordinari da esplorare!"
+52
View File
@@ -0,0 +1,52 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-02 19:44-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: guide.php:88 guide.php:128
msgid "Destinations Guide"
msgstr ""
#: guide.php:129 guide.php:154
msgid "This is a work in progress, please be indulgent."
msgstr ""
#: guide.php:139
#, php-format
msgid "%s destinations"
msgstr ""
#: guide.php:152
msgid "Back to categories"
msgstr ""
#: guide.php:168
#, php-format
msgid "%s people"
msgstr ""
#: guide.php:171
#, php-format
msgid "traffic %s"
msgstr ""
#: guide.php:182
msgid ""
"The realm of destinations you seek has eluded our grasp, spirited away by "
"elusive knomes. Rally the grid managers, let them venture forth to curate a "
"grand tapestry of remarkable places for your exploration!"
msgstr ""
Binary file not shown.
+52
View File
@@ -0,0 +1,52 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: gpt-po v1.0.7\n"
"Language-Team: \n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0.1\n"
#: guide.php:88 guide.php:128
msgid "Destinations Guide"
msgstr "Guia de Destinos"
#: guide.php:129 guide.php:153
msgid "This is a work in progress, please be indulgent."
msgstr "Este é um trabalho em andamento, por favor, seja indulgente."
#: guide.php:138
#, php-format
msgid "%s destinations"
msgstr "%s destinos"
#: guide.php:151
msgid "Back to categories"
msgstr "Voltar para categorias"
#: guide.php:167
#, php-format
msgid "%s people"
msgstr "%s pessoas"
#: guide.php:170
#, php-format
msgid "traffic %s"
msgstr "tráfego %s"
#: guide.php:182
msgid ""
"The realm of destinations you seek has eluded our grasp, spirited away by elusive knomes. Rally the grid managers, let "
"them venture forth to curate a grand tapestry of remarkable places for your exploration!"
msgstr ""
"O reino de destinos que você procura escapou de nosso alcance, levado embora por gnomos elusivos. Reúna os gerentes da "
"grid, deixe-os se aventurar para criar uma grande tapeçaria de lugares notáveis para sua exploração!"
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
find * -iname "*.php" | egrep -v -e vendor -e node_modules | xargs -d"\n" xgettext --from-code=UTF-8 -o locales/messages.pot
pot=locales/messages.pot
for lang in fr_FR de_DE cy_GB it_IT pt_BR
do
file="locales/$lang/LC_MESSAGES/messages.po"
mkdir -p "$(dirname "$file")" && touch $file \
&& gpt-po sync --po "$file" --pot "$pot" \
&& gpt-po translate --po "$file" -l $lang \
&& poedit "$file"
done