Browse Source

Move master translation file away from util

- Rewrite translation documentation
- Delete unused util/strings.php
- Updated references to util/messages.po and util/strings.php
tags/2019.01
Hypolite Petovan 7 months ago
parent
commit
9102a37b37

+ 1
- 1
.tx/config View File

@@ -3,7 +3,7 @@ host = https://www.transifex.com
3 3
 
4 4
 [friendica.messagespo]
5 5
 file_filter = view/lang/<lang>/messages.po
6
-source_file = util/messages.po
6
+source_file = view/lang/C/messages.po
7 7
 source_lang = en
8 8
 type = PO
9 9
 

+ 0
- 101
README.translate.md View File

@@ -1,101 +0,0 @@
1
-Friendica translations
2
-======================
3
-
4
-Translation Process
5
--------------------
6
-
7
-The strings used in the UI of Friendica is translated at [Transifex] [1] and then included in the git repository at github.
8
-If you want to help with translation for any language, be it correcting terms or translating friendica to a currently not supported language, please register an account at transifex.com and contact the friendica translation team there.
9
-
10
-Translating friendica is simple.
11
-Just use the online tool at transifex.
12
-If you don't want to deal with git & co. that is fine, we check the status of the translations regularly and import them into the source tree at github so that others can use them.
13
-
14
-We do not include every translation from transifex in the source tree to avoid a scattered and disturbed overall experience.
15
-As an uneducated guess we have a lower limit of 50% translated strings before we include the language (for the core messages.po file, addont translation will be included once all strings of an addon are translated.
16
-This limit is judging only by the amount of translated strings under the assumption that the most prominent strings for the UI will be translated first by a translation team.
17
-If you feel your translation useable before this limit, please contact us and we will probably include your teams work in the source tree.
18
-
19
-If you want to help translating, please concentrate on the core messages.po file first.
20
-We will only include translations with a sufficient translated messages.po file.
21
-Translations of addons will only be included, when the core file is included as well.
22
-
23
-If you want to get your work into the source tree yourself, feel free to do so and contact us with and question that arises.
24
-The process is simple and friendica ships with all the tools necessary.
25
-
26
-The location of the translated files in the source tree is
27
-    /view/lang/LNG-CODE/
28
-where LNG-CODE is the language code used, e.g. de for German or fr for French.
29
-The translated strings come as a "message.po" file from transifex which needs to be translated into the PHP file friendica uses.
30
-To do so, place the file in the directory mentioned above and use the "po2php" command from the console.
31
-*Please note that the console tool has to be called from the base directory of your Friendica installation.*
32
-
33
-Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.
34
-
35
-    1. Navigate at the command prompt to the base directory of your
36
-       friendica installation
37
-
38
-    2. Execute the po2php command, which will place the translation
39
-       in the strings.php file that is used by friendica.
40
-
41
-       $> php bin/console.php po2php view/lang/de/messages.po
42
-
43
-       The output of the script will be placed at view/lang/de/strings.php where
44
-       friendica is expecting it, so you can test your translation immediately.
45
-
46
-    3. Visit your friendica page to check if it still works in the language you
47
-       just translated. If not try to find the error, most likely PHP will give
48
-       you a hint in the log/warnings.about the error.
49
-
50
-       For debugging you can also try to "run" the file with PHP. This should
51
-       not give any output if the file is ok but might give a hint for
52
-       searching the bug in the file.
53
-
54
-       $> php view/lang/de/strings.php
55
-
56
-    4. commit the two files with a meaningful commit message to your git
57
-       repository, push it to your fork of the friendica repository at github and
58
-       issue a pull request for that commit.
59
-
60
-You should translate the PO files at Transifex.
61
-Otherwise your work might get lost, when the translation from Transifex is included to the Friendica repository after it was updated there.
62
-
63
-Utilities
64
----------
65
-
66
-Additional to the po2php command there are some more utilities for translation in the console.
67
-If you only want to translate friendica into another language you wont need any of these tools most likely but it gives you an idea how the translation process of friendica works.
68
-
69
-For further information see the utils/README file.
70
-
71
-Transifex-Client
72
-----------------
73
-
74
-Transifex has a client program which let you interact with the translation files in a similar way to git.
75
-Help for the client can be found at the [Transifex Help Center] [2].
76
-Here we will only cover basic usage.
77
-
78
-After installation of the client, you should have a `tx` command available on your system.
79
-To use it, first create a configuration file with your credentials.
80
-On Linux this file should be placed into your home directory `~/.transifexrc`.
81
-The content of the file should be something like the following:
82
-
83
-    [https://www.transifex.com]
84
-    username = user
85
-    token =
86
-    password = p@ssw0rd
87
-    hostname = https://www.transifex.com
88
-
89
-Since Friendica version 3.5.1 we ship configuration files for the Transifex client in the core repository and the addon repository.
90
-To update the translation files after you have translated strings of e.g. Esperanto in the web-UI of transifex you can use `tx` to download the file.
91
-
92
-    $> tx pull -l eo
93
-
94
-And then use the `po2php` command described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
95
-
96
-    $> php bin/console.php po2php view/lang/eo/messages.po
97
-
98
-Afterwards, just commit the two changed files to a feature branch of your Friendica repository, push the changes to github and open a pull request for your changes.
99
-
100
-[1]:   https://www.transifex.com/projects/p/friendica/
101
-[2]:   https://docs.transifex.com/client/introduction

+ 1
- 1
bin/run_xgettext.sh View File

@@ -45,7 +45,7 @@ case "$MODE" in
45 45
 	;;
46 46
 	'default')
47 47
 		cd "$FULLPATH/.."
48
-		OUTFILE="$FULLPATH/../util/messages.po"
48
+		OUTFILE="$FULLPATH/../view/lang/C/messages.po"
49 49
 		FINDSTARTDIR="."
50 50
 		# skip addon folder
51 51
 		FINDOPTS="( -wholename */addon -or -wholename */addons -or -wholename */addons-extra -or -wholename */smarty3 ) -prune -o"

+ 45
- 69
doc/translations.md View File

@@ -3,84 +3,52 @@ Friendica translations
3 3
 
4 4
 * [Home](help)
5 5
 
6
-Translation Process
7
--------------------
6
+## Overview
8 7
 
9
-The strings used in the UI of Friendica are translated at [Transifex] [1] and then included in the git repository at github.
10
-If you want to help with translation for any language, be it correcting terms or translating friendica to a currently not supported language, please register an account at Transifex.com and contact the friendica translation team there.
8
+The Friendica translation process is based on `gettext` PO files.
11 9
 
12
-Translating friendica is simple.
13
-Just use the online tool at Transifex.
14
-If you don't want to deal with git & co. that is fine, we check the status of the translations regularly and import them into the source tree at github so that others can use them.
10
+Basic worflow:
11
+1. `xgettext` is used to collect translation strings across the project in the master PO file located in `view/lang/C/messages.po`.
12
+2. This file makes translations strings available at [the Transifex Friendica page](https://www.transifex.com/Friendica/friendica/dashboard/).
13
+3. The translation itself is done at Transifex by volunteers.
14
+4. The resulting PO files by languages are manually updated in `view/lang/<language>/messages.po`.
15
+5. PO files are converted to PHP arrays in `view/lang/<language>/strings.php` that are ultimately used by Friendica to display the translations.
15 16
 
16
-We do not include every translation from Transifex in the source tree to avoid a scattered and disturbed overall experience.
17
-As an uneducated guess we have a lower limit of 50% translated strings before we include the language (for the core messages.po file, addon translation will be included once all strings of an addon are translated.
18
-This limit is judging only by the amount of translated strings under the assumption that the most prominent strings for the UI will be translated first by a translation team.
19
-If you feel your translation usable before this limit, please contact us and we will probably include your teams work in the source tree.
17
+## Translate Friendica in your favorite language
20 18
 
21
-If you want to help translating, please concentrate on the core messages.po file first.
22
-We will only include translations with a sufficient translated messages.po file.
23
-Translations of addons will only be included, when the core file is included as well.
19
+Thank you for your interest in improving Friendica's translation!
20
+Please register a free Transifex account and ask over at [the Transifex Friendica page](https://www.transifex.com/Friendica/friendica/dashboard/) to join the translation team for your favorite language.
24 21
 
25
-If you want to get your work into the source tree yourself, feel free to do so and contact us with and questions that arise.
26
-The process is simple and friendica ships with all the tools necessary.
22
+As a rule of thumb, we add support for a language in Friendica when at least 50% of the strings have been translated to avoid a scattered experience.
23
+For addons, we add support for a language when all the strings for this addon have been translated and only if we already support the language in Friendica.
27 24
 
28
-The location of the translated files in the source tree is
29
-    /view/lang/LNG-CODE/
30
-where LNG-CODE is the language code used, e.g. de for German or fr for French.
31
-The translated strings come as a "message.po" file from Transifex which needs to be translated into the PHP file friendica uses.
32
-To do so, place the file in the directory mentioned above and use the "po2php" command from the Friendica Console.
25
+## Add new translation strings
33 26
 
34
-Assuming you want to convert the German localization which is placed in view/lang/de/message.po you would do the following.
27
+### Core
35 28
 
36
-    1. Navigate at the command prompt to the base directory of your
37
-       friendica installation
29
+Once you have added new translation strings in your code changes, please run `bin/run_xgettext.sh` from the base Friendica directory and commit the updated `view/lang/C/messages.po` to your branch.
38 30
 
39
-    2. Execute the po2php command, which will place the translation
40
-       in the strings.php file that is used by friendica.
31
+### Addon
41 32
 
42
-       $> php bin/console.php po2php view/lang/de/messages.po
33
+If you have the `friendica-addons` repository in the `addon` directory of your Friendica cloned repository, just run `bin/run_xgettext.sh -a <addon_name>` from the base Friendica directory.
43 34
 
44
-       The output of the script will be placed at view/lang/de/strings.php where
45
-       friendica is expecting it, so you can test your translation immediately.
46
-       *Please note that the console tool has to be called from the base directory of your Friendica installation.*
35
+Otherwise:
47 36
 
48
-    3. Visit your friendica page to check if it still works in the language you
49
-       just translated. If not try to find the error, most likely PHP will give
50
-       you a hint in the log/warnings.about the error.
37
+	cd /path/to/friendica-addons/<addon_name>
38
+	/path/to/friendica/bin/run_xgettext.sh -s
51 39
 
52
-       For debugging you can also try to "run" the file with PHP. This should
53
-       not give any output if the file is ok but might give a hint for
54
-       searching the bug in the file.
40
+In either case, you need to commit the updated `<addon_name>/lang/C/messages.po`.
55 41
 
56
-       $> php view/lang/de/strings.php
42
+## Update translations from Transifex
57 43
 
58
-    4. commit the two files with a meaningful commit message to your git
59
-       repository, push it to your fork of the friendica repository at github and
60
-       issue a pull request for that commit.
44
+Please download the Transifex file "for use" in `view/lang/<language>/messages.po`.
61 45
 
62
-You should translate the PO files at Transifex.
63
-Otherwise your work might get lost, when the translation from Transifex is included to the Friendica repository after it was updated there.
46
+Then run `bin/console po2php view/lang/<language>/messages.po` to update the related `strings.php` file.
64 47
 
65
-Utilities
66
----------
48
+### Using the Transifex client
67 49
 
68
-Additional to the po2php command there are some more utilities for translation in the console.
69
-If you only want to translate friendica into another language you wont need any of these tools most likely but it gives you an idea how the translation process of friendica works.
70
-
71
-For further information see the utils/README file.
72
-
73
-Help, Tobias asked me to regenerate the master messages.po file!
74
-----------------------------------------------------------------
75
-
76
-Don't panic.
77
-Just run `bin/run_xgettext.sh` from your base Friendica directory and commit `util/messages.po` to your branch. 
78
-
79
-Transifex-Client
80
-----------------
81
-
82
-Transifex has a client program which let you interact with the translation files in a similar way to git.
83
-Help for the client can be found at the [Transifex Help Center] [2].
50
+Transifex has a client program which allows you to sync files between your cloned Friendica repository and Transifex.
51
+Help for the client can be found at the [Transifex Help Center](https://docs.transifex.com/client/introduction).
84 52
 Here we will only cover basic usage.
85 53
 
86 54
 After installation of the client, you should have a `tx` command available on your system.
@@ -88,23 +56,31 @@ To use it, first create a configuration file with your credentials.
88 56
 On Linux this file should be placed into your home directory `~/.transifexrc`.
89 57
 The content of the file should be something like the following:
90 58
 
91
-    [https://www.Transifex.com]
59
+    [https://www.transifex.com]
92 60
     username = user
93 61
     token =
94 62
     password = p@ssw0rd
95
-    hostname = https://www.Transifex.com
63
+    hostname = https://www.transifex.com
96 64
 
97
-Since Friendica version 3.5.1 we ship configuration files for the Transifex client in the core repository and the addon repository.
98
-To update the translation files after you have translated strings of e.g. Esperanto in the web-UI of Transifex you can use `tx` to download the file.
65
+Since Friendica version 3.5.1 we ship configuration files for the Transifex client in the core repository and the addon repository in `.tx/config`.
66
+To update the PO files after you have translated strings of e.g. Esperanto on the Transifex website you can use `tx` to download the updated PO file in the right location.
99 67
 
100 68
     $> tx pull -l eo
101 69
 
102
-And then use the `po2php` command described above to convert the `messages.po` file to the `strings.php` file Friendica is loading.
70
+Then run `bin/console po2php view/lang/<language>/messages.po` to update the related `strings.php` file.
71
+
72
+## Translation functions usage
103 73
 
104
-    $> php bin/console.php po2php view/lang/eo/messages.po
74
+### Basic usage
105 75
 
106
-Afterwards, just commit the two changed files to a feature branch of your Friendica repository, push the changes to github and open a pull request for your changes.
76
+- `Friendica\Core\L10n::t('Label')` => `Label`
77
+- `Friendica\Core\L10n::t('Label %s', 'test')` => `Label test`
107 78
 
108
-[1]:   https://www.Transifex.com/projects/p/friendica/
109
-[2]:   https://docs.Transifex.com/client/introduction
79
+### Plural
110 80
 
81
+- `Friendica\Core\L10n::tt('Label', 'Labels', 1)` => `Label`
82
+- `Friendica\Core\L10n::tt('Label', 'Labels', 3)` => `Labels`
83
+- `Friendica\Core\L10n::tt('%d Label', '%d Labels', 1)` => `1 Label`
84
+- `Friendica\Core\L10n::tt('%d Label', '%d Labels', 3)` => `3 Labels`
85
+- `Friendica\Core\L10n::tt('%d Label', 'Labels %2%s %3%s', 1, 'test', 'test2')` => `Label test test2`
86
+- `Friendica\Core\L10n::tt('%d Label', 'Labels %2%s %3%s', 3, 'test', 'test2')` => `Labels test test2`

+ 2
- 2
src/Core/Console/PhpToPo.php View File

@@ -27,7 +27,7 @@ Description
27 27
 
28 28
 Options
29 29
 	-p <n>        Number of plural forms. Default: 2
30
-	--base <file> Path to base messages.po file. Default: util/messages.po
30
+	--base <file> Path to base messages.po file. Default: view/lang/C/messages.po
31 31
 	-h|--help|-?  Show help information
32 32
 	-v            Show more debug information.
33 33
 HELP;
@@ -107,7 +107,7 @@ HELP;
107 107
 		$out .= sprintf('"Plural-Forms: nplurals=%s; plural=%s;\n"', $lang_pnum, $lang_logic) . "\n";
108 108
 		$out .= "\n";
109 109
 
110
-		$base_path = $this->getOption('base', 'util' . DIRECTORY_SEPARATOR . 'messages.po');
110
+		$base_path = $this->getOption('base', 'view/lang/C/messages.po');
111 111
 
112 112
 		// load base messages.po and extract msgids
113 113
 		$base_msgids = [];

+ 1
- 1
src/Core/Console/PoToPhp.php View File

@@ -61,7 +61,7 @@ HELP;
61 61
 
62 62
 		$outfile = dirname($pofile) . DIRECTORY_SEPARATOR . 'strings.php';
63 63
 
64
-		if (strstr($outfile, 'util')) {
64
+		if (basename(dirname($pofile)) == 'C') {
65 65
 			$lang = 'en';
66 66
 		} else {
67 67
 			$lang = str_replace('-', '_', basename(dirname($pofile)));

+ 0
- 2
src/Core/Console/Typo.php View File

@@ -86,8 +86,6 @@ HELP;
86 86
 			$this->out('String files');
87 87
 		}
88 88
 
89
-		$this->checkFile($php_path, 'util/strings.php');
90
-
91 89
 		$files = glob('view/lang/*/strings.php');
92 90
 		$this->checkFiles($php_path, $files);
93 91
 

+ 0
- 1776
util/strings.php
File diff suppressed because it is too large
View File


util/messages.po → view/lang/C/messages.po View File


Loading…
Cancel
Save