Browse Source

Merge pull request #2821 from Hypolite/Issue-#2817

Fix #2817 - Move translation language folder in a subfolder of view
tags/3.5.1
Tobias Diekershoff 4 years ago
committed by GitHub
parent
commit
82dcc3fe79
41 changed files with 68 additions and 68 deletions
  1. +5
    -5
      README.translate.md
  2. +5
    -5
      doc/translations.md
  3. +6
    -6
      include/pgettext.php
  4. +10
    -10
      include/text.php
  5. +36
    -36
      util/README
  6. +1
    -1
      util/make_credits.py
  7. +5
    -5
      util/typo.php
  8. +0
    -0
      view/lang/bg/messages.po
  9. +0
    -0
      view/lang/bg/strings.php
  10. +0
    -0
      view/lang/ca/messages.po
  11. +0
    -0
      view/lang/ca/strings.php
  12. +0
    -0
      view/lang/cs/messages.po
  13. +0
    -0
      view/lang/cs/strings.php
  14. +0
    -0
      view/lang/de/messages.po
  15. +0
    -0
      view/lang/de/strings.php
  16. +0
    -0
      view/lang/eo/messages.po
  17. +0
    -0
      view/lang/eo/strings.php
  18. +0
    -0
      view/lang/es/messages.po
  19. +0
    -0
      view/lang/es/strings.php
  20. +0
    -0
      view/lang/fr/messages.po
  21. +0
    -0
      view/lang/fr/strings.php
  22. +0
    -0
      view/lang/is/messages.po
  23. +0
    -0
      view/lang/is/strings.php
  24. +0
    -0
      view/lang/it/messages.po
  25. +0
    -0
      view/lang/it/strings.php
  26. +0
    -0
      view/lang/nb-no/messages.po
  27. +0
    -0
      view/lang/nb-no/strings.php
  28. +0
    -0
      view/lang/nl/messages.po
  29. +0
    -0
      view/lang/nl/strings.php
  30. +0
    -0
      view/lang/pl/messages.po
  31. +0
    -0
      view/lang/pl/strings.php
  32. +0
    -0
      view/lang/pt-br/messages.po
  33. +0
    -0
      view/lang/pt-br/strings.php
  34. +0
    -0
      view/lang/ro/messages.po
  35. +0
    -0
      view/lang/ro/strings.php
  36. +0
    -0
      view/lang/ru/messages.po
  37. +0
    -0
      view/lang/ru/strings.php
  38. +0
    -0
      view/lang/sv/messages.po
  39. +0
    -0
      view/lang/sv/strings.php
  40. +0
    -0
      view/lang/zh-cn/messages.po
  41. +0
    -0
      view/lang/zh-cn/strings.php

+ 5
- 5
README.translate.md View File

@@ -24,12 +24,12 @@ If you want to get your work into the source tree yourself, feel free to do so a
The process is simple and friendica ships with all the tools necessary.

The location of the translated files in the source tree is
/view/LNG-CODE/
/view/lang/LNG-CODE/
where LNG-CODE is the language code used, e.g. de for German or fr for French.
The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
To do so, place the file in the directory mentioned above and use the "po2php" utility from the util directory of your friendica installation.

Assuming you want to convert the German localization which is placed in view/de/message.po you would do the following.
Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.

1. Navigate at the command prompt to the base directory of your
friendica installation
@@ -37,9 +37,9 @@ Assuming you want to convert the German localization which is placed in view/de/
2. Execute the po2php script, which will place the translation
in the strings.php file that is used by friendica.

$> php util/po2php.php view/de/messages.po
$> php util/po2php.php view/lang/de/messages.po

The output of the script will be placed at view/de/strings.php where
The output of the script will be placed at view/lang/de/strings.php where
friendica is expecting it, so you can test your translation immediately.

3. Visit your friendica page to check if it still works in the language you
@@ -50,7 +50,7 @@ Assuming you want to convert the German localization which is placed in view/de/
not give any output if the file is ok but might give a hint for
searching the bug in the file.

$> php view/de/strings.php
$> php view/lang/de/strings.php

4. commit the two files with a meaningful commit message to your git
repository, push it to your fork of the friendica repository at github and


+ 5
- 5
doc/translations.md View File

@@ -24,12 +24,12 @@ If you want to get your work into the source tree yourself, feel free to do so a
The process is simple and friendica ships with all the tools necessary.

The location of the translated files in the source tree is
/view/LNG-CODE/
/view/lang/LNG-CODE/
where LNG-CODE is the language code used, e.g. de for German or fr for French.
The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
To do so, place the file in the directory mentioned above and use the "po2php" utility from the util directory of your friendica installation.

Assuming you want to convert the German localization which is placed in view/de/message.po you would do the following.
Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.

1. Navigate at the command prompt to the base directory of your
friendica installation
@@ -37,9 +37,9 @@ Assuming you want to convert the German localization which is placed in view/de/
2. Execute the po2php script, which will place the translation
in the strings.php file that is used by friendica.

$> php util/po2php.php view/de/messages.po
$> php util/po2php.php view/lang/de/messages.po

The output of the script will be placed at view/de/strings.php where
The output of the script will be placed at view/lang/de/strings.php where
friendica is expecting it, so you can test your translation immediately.

3. Visit your friendica page to check if it still works in the language you
@@ -50,7 +50,7 @@ Assuming you want to convert the German localization which is placed in view/de/
not give any output if the file is ok but might give a hint for
searching the bug in the file.

$> php view/de/strings.php
$> php view/lang/de/strings.php

4. commit the two files with a meaningful commit message to your git
repository, push it to your fork of the friendica repository at github and


+ 6
- 6
include/pgettext.php View File

@@ -41,7 +41,7 @@ function get_browser_language() {

if(isset($langs) && count($langs)) {
foreach ($langs as $lang => $v) {
if(file_exists("view/$lang") && is_dir("view/$lang")) {
if(file_exists("view/lang/$lang") && is_dir("view/lang/$lang")) {
$preferred = $lang;
break;
}
@@ -112,8 +112,8 @@ function load_translation_table($lang) {
}
}

if(file_exists("view/$lang/strings.php")) {
include("view/$lang/strings.php");
if(file_exists("view/lang/$lang/strings.php")) {
include("view/lang/$lang/strings.php");
}

}}
@@ -171,11 +171,11 @@ function string_plural_select_default($n) {
*/
function get_avaiable_languages() {
$lang_choices = array();
$langs = glob('view/*/strings.php'); /**/
$langs = glob('view/lang/*/strings.php'); /**/

if(is_array($langs) && count($langs)) {
if(! in_array('view/en/strings.php',$langs))
$langs[] = 'view/en/';
if(! in_array('view/lang/en/strings.php',$langs))
$langs[] = 'view/lang/en/';
asort($langs);
foreach($langs as $l) {
$t = explode("/",$l);


+ 10
- 10
include/text.php View File

@@ -581,14 +581,14 @@ function get_intltext_template($s) {
if(! isset($lang))
$lang = 'en';

if(file_exists("view/$lang$engine/$s")) {
if(file_exists("view/lang/$lang$engine/$s")) {
$stamp1 = microtime(true);
$content = file_get_contents("view/$lang$engine/$s");
$content = file_get_contents("view/lang/$lang$engine/$s");
$a->save_timestamp($stamp1, "file");
return $content;
} elseif(file_exists("view/en$engine/$s")) {
} elseif(file_exists("view/lang/en$engine/$s")) {
$stamp1 = microtime(true);
$content = file_get_contents("view/en$engine/$s");
$content = file_get_contents("view/lang/en$engine/$s");
$a->save_timestamp($stamp1, "file");
return $content;
} else {
@@ -928,11 +928,11 @@ function contact_block() {
* string 'thumb' => The contact picture
* string 'click' => js code which is performed when clicking on the contact
* @param boolean $redirect If true try to use the redir url if it's possible
* @param string $class CSS class for the
* @param string $class CSS class for the
* @param boolean $textmode If true display the contacts as text links
* if false display the contacts as picture links
* @return string Formatted html
* @return string Formatted html
*/
function micropro($contact, $redirect = false, $class = '', $textmode = false) {

@@ -2087,7 +2087,7 @@ function formatBytes($bytes, $precision = 2) {

/**
* @brief translate and format the networkname of a contact
*
*
* @param string $network
* Networkname of the contact (e.g. dfrn, rss and so on)
* @param sting $url
@@ -2132,7 +2132,7 @@ function text_highlight($s,$lang) {
$s = trim(html_entity_decode($s,ENT_COMPAT));
$s = str_replace(" ","\t",$s);

// The highlighter library insists on an opening php tag for php code blocks. If
// The highlighter library insists on an opening php tag for php code blocks. If
// it isn't present, nothing is highlighted. So we're going to see if it's present.
// If not, we'll add it, and then quietly remove it after we get the processed output back.

@@ -2141,7 +2141,7 @@ function text_highlight($s,$lang) {
$s = '<?php' . "\n" . $s;
$tag_added = true;
}
}
}

$renderer = new Text_Highlighter_Renderer_HTML($options);
$hl = Text_Highlighter::factory($lang);


+ 36
- 36
util/README View File

@@ -1,47 +1,47 @@
Utilities

typo.php - is a crude syntax checker to avoid checking in files with simple
typos. It basically just loads each of our project files at once. Run from
typo.php - is a crude syntax checker to avoid checking in files with simple
typos. It basically just loads each of our project files at once. Run from
cmdline and see if any parsing errors are reported.



Internationalisation

extract.php - extracts translatable strings from our project files. It
currently doesn't pick up strings in other libraries we might be using such as
extract.php - extracts translatable strings from our project files. It
currently doesn't pick up strings in other libraries we might be using such as
tinymce and the HTML parsers.

In order for extract to do its job, every use of the t() translation function
In order for extract to do its job, every use of the t() translation function
must be preceded by one space. The string also can not contain parentheses. If
parens are required in a string which requires translation, please use hex escapes.

\x28 = (
\x29 = )

This only applies to English. Other languages may use parens in strings
This only applies to English. Other languages may use parens in strings
because they don't require extraction.
strings.php - a recent run of the strings program. This provides output that
is suitable for direct inclusion in the program.
is suitable for direct inclusion in the program.

There are also translatable strings in the various files in the view/en
directory. By setting $lang = 'something' in .htconfig.php, the application
will search for view/something/filename prior to the English version in
view/en/filename when loading templates and view files.
There are also translatable strings in the various files in the view/lang/en
directory. By setting $lang = 'something' in .htconfig.php, the application
will search for view/lang/something/filename prior to the English version in
view/lang/en/filename when loading templates and view files.

The translated string table should be placed in view/$lang/strings.php for
The translated string table should be placed in view/lang/$lang/strings.php for
automatic inclusion.

You are not restricted to using known languages. You may also use this to
translate the software into "pirate", "surfer" or merely to replace certain
text which you don't care for.
text which you don't care for.

Note: The view/en directory contains many HTML template files, some of which
Note: The view/lang/en directory contains many HTML template files, some of which
only have a few words of English text amongst the HTML. Over time we will move
the translation to the replace_macros() function which calls these files and
then relocate the files to the view directory. The files in the top-level view
directory are template files which do not require translation.
the translation to the replace_macros() function which calls these files and
then relocate the files to the view directory. The files in the top-level view
directory are template files which do not require translation.


Placeholders
@@ -61,7 +61,7 @@ e.g.

Plural

The tt() function supports plural form. Script extract.php write this in
The tt() function supports plural form. Script extract.php write this in
strings.php as an array, one string for every plural form language supports:

$a->string["%d message sent"] = Array(
@@ -82,12 +82,12 @@ Xgettext and .po workflow
This script runs xgettext on source tree, extracting strings from t() and tt()
functions, and creates a util/messages.po file.

$ cd util; ./run_xgettext.sh
$ cd util; ./run_xgettext.sh

2. copy util/messages.po to view/<langauage>/messages.po
Replace <language> with the language you are working on - e.g. 'es', 'fr', 'de', etc.
2. copy util/messages.po to view/lang/<language>/messages.po
Replace <language> with the language you are working on - e.g. 'es', 'fr', 'de', etc.

3. open view/<langauage>/messages.po with a text editor and fill in infos in
3. open view/lang/<language>/messages.po with a text editor and fill in infos in
"Last-Translator: FULL NAME <EMAIL@ADDRESS>"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
@@ -97,30 +97,30 @@ Xgettext and .po workflow
"Language-Team: Pirate Friendika <pirate-friendika-ml@host.com>\n"
"Language: pi\n"
)
For the line
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
read GNU gettext manual at
read GNU gettext manual at
http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html
4. You could then translate the strings in text editor, but I suggest to use one
of the many .po editors out there, like QtLinguist
5. run
$ php util/po2php.php view/<language>/messages.po
5. run
$ php util/po2php.php view/lang/<language>/messages.po
to create the strings.php file
When strings are added or modified in source, you could run
$ cd util; ./run_xgettext.sh ../view/<language>/messages.po
$ cd util; ./run_xgettext.sh ../view/lang/<language>/messages.po
to extract strings from source files and join them with the existing .po file:
new strings are added, the existing are not overwritten.
If you already translated Friendica using strings.php, you could import your old
translation to messages.po. Run:
$ php util/php2po.php view/<language>/strings.php
$ php util/php2po.php view/lang/<language>/strings.php


You may also use the util/string_translator.php web interface to translate the string file, but it is disabled for website security reasons. The web server will need write permission to your language directories and the "Deny ..." line in util/.htaccess will need to be modified or commented to use the utility.


You may also use the util/string_translator.php web interface to translate the string file, but it is disabled for website security reasons. The web server will need write permission to your language directories and the "Deny ..." line in util/.htaccess will need to be modified or commented to use the utility.


+ 1
- 1
util/make_credits.py View File

@@ -67,7 +67,7 @@ os.chdir(path)
# get the translators
print('> getting translators')
intrans = False
for f in glob.glob(path+'/view/*/messages.po'):
for f in glob.glob(path+'/view/lang/*/messages.po'):
i = open(f, 'r')
l = i.readlines()
i.close()


+ 5
- 5
util/typo.php View File

@@ -1,6 +1,6 @@
<?php
// Tired of chasing typos and finding them after a commit.
// Run this from cmdline in basedir and quickly see if we've
// Tired of chasing typos and finding them after a commit.
// Run this from cmdline in basedir and quickly see if we've
// got any parse errors in our application files.


@@ -9,7 +9,7 @@
ini_set('log_errors','0');

include 'boot.php';
$a = new App();

if(x($a->config,'php_path'))
@@ -29,7 +29,7 @@
foreach($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}
echo "Directory: object\n";
$files = glob('object/*.php');
foreach($files as $file) {
@@ -53,7 +53,7 @@
echo 'util/strings.php' . "\n";
passthru("$phpath -l util/strings.php", $ret); $ret===0 or die();

$files = glob('view/*/strings.php');
$files = glob('view/lang/*/strings.php');
foreach($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
}

view/bg/messages.po → view/lang/bg/messages.po View File


view/bg/strings.php → view/lang/bg/strings.php View File


view/ca/messages.po → view/lang/ca/messages.po View File


view/ca/strings.php → view/lang/ca/strings.php View File


view/cs/messages.po → view/lang/cs/messages.po View File


view/cs/strings.php → view/lang/cs/strings.php View File


view/de/messages.po → view/lang/de/messages.po View File


view/de/strings.php → view/lang/de/strings.php View File


view/eo/messages.po → view/lang/eo/messages.po View File


view/eo/strings.php → view/lang/eo/strings.php View File


view/es/messages.po → view/lang/es/messages.po View File


view/es/strings.php → view/lang/es/strings.php View File


view/fr/messages.po → view/lang/fr/messages.po View File


view/fr/strings.php → view/lang/fr/strings.php View File


view/is/messages.po → view/lang/is/messages.po View File


view/is/strings.php → view/lang/is/strings.php View File


view/it/messages.po → view/lang/it/messages.po View File


view/it/strings.php → view/lang/it/strings.php View File


view/nb-no/messages.po → view/lang/nb-no/messages.po View File


view/nb-no/strings.php → view/lang/nb-no/strings.php View File


view/nl/messages.po → view/lang/nl/messages.po View File


view/nl/strings.php → view/lang/nl/strings.php View File


view/pl/messages.po → view/lang/pl/messages.po View File


view/pl/strings.php → view/lang/pl/strings.php View File


view/pt-br/messages.po → view/lang/pt-br/messages.po View File


view/pt-br/strings.php → view/lang/pt-br/strings.php View File


view/ro/messages.po → view/lang/ro/messages.po View File


view/ro/strings.php → view/lang/ro/strings.php View File


view/ru/messages.po → view/lang/ru/messages.po View File


view/ru/strings.php → view/lang/ru/strings.php View File


view/sv/messages.po → view/lang/sv/messages.po View File


view/sv/strings.php → view/lang/sv/strings.php View File


view/zh-cn/messages.po → view/lang/zh-cn/messages.po View File


view/zh-cn/strings.php → view/lang/zh-cn/strings.php View File


Loading…
Cancel
Save