Skip to content

Commit 49944a4

Browse files
committed
added contribution file and fixed code styles
1 parent bad51a3 commit 49944a4

7 files changed

Lines changed: 65 additions & 17 deletions

File tree

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Contributing to Gettext
2+
=======================
3+
4+
Looking to contribute something to this library? Here's how you can help.
5+
6+
## Bugs
7+
8+
A bug is a demonstrable problem that is caused by the code in the repository. Good bug reports are extremely helpful – thank you!
9+
10+
Please try to be as detailed as possible in your report. Include specific information about the environment – version of PHP, version of gettext, etc, and steps required to reproduce the issue.
11+
12+
## Pull Requests
13+
14+
Good pull requests – patches, improvements, new features – are a fantastic help. New extractors or generator are welcome. Before create a pull request, please follow these instructions:
15+
16+
* The code must be PSR-2 compliant
17+
* Write some tests
18+
19+
## Contributors
20+
21+
* [oscarotero](https://github.com/oscarotero) (Creator and maintainer)
22+
* [esnoeijs](https://github.com/esnoeijs) (plural parser)
23+
* [leom](https://github.com/leom) (Jed fixes)
24+
* [eusonlito](https://github.com/eusonlito) (Blade extractor)
25+
* [vvh-empora](https://github.com/vvh-empora) (fixes)
26+
* [mlocati](https://github.com/mlocati) (Mo generator/extractor, locales data, etc)
27+
* [and many more...](https://github.com/oscarotero/Gettext/graphs/contributors)

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,10 @@ This package contains the following classes:
5656

5757
* `Gettext\Translation` - A translation definition
5858
* `Gettext\Translations` - A collection of translations
59-
* `Gettext\Translator` - Emulate gettext functions in your php templates
59+
* `Gettext\Translator` - Use the translations in your php templates
6060
* `Gettext\Extractors\*` - Extract gettext values from various sources
6161
* `Gettext\Generators\*` - Generate gettext formats
6262

63-
And the file `translator_functions.php` that provide the gettext functions to use in your templates.
64-
65-
6663
## Translation
6764

6865
The `Gettext\Translation` class stores all information about a translation: the original text, the translated text, source references, comments, etc.
@@ -100,7 +97,7 @@ $insertedTranslation = $translations->insert('comments', 'One comments', '%s com
10097
//Find a specific translation
10198
$translation = $translations->find('comments', 'One comments');
10299

103-
//Edit headers, the domain value, etc
100+
//Edit headers, domain, etc
104101
$translations->setHeader('Last-Translator', 'Oscar Otero');
105102
$translations->setDomain('my-blog');
106103
```
@@ -131,7 +128,7 @@ The available extractors are the following:
131128

132129
## Generators
133130

134-
The generators export a `Gettext\Translations` instance in any format (po, mo, array, etc).
131+
The generators export a `Gettext\Translations` instance to any format (po, mo, array, etc).
135132

136133
```php
137134
//Save to a file
@@ -176,7 +173,7 @@ $t = new Translator();
176173

177174
//Load the translations using one of the following ways:
178175

179-
// 1. from php files (generated with PhpArray)
176+
// 1. from php files (generated by Gettext\Extractors\PhpArray)
180177
$t->loadTranslations('locales/gl.php');
181178

182179
// 2. using the array directly
@@ -197,7 +194,7 @@ To ease the use of translations in your php templates, you can use the provided
197194
//First load the gettext functions and passing the instance
198195
Translator::initGettextFunctions($t);
199196

200-
echo __('apple'); //Returns Mazá
197+
echo __('apple'); //returns Mazá
201198

202199
__e('apple'); //echo Mazá
203200
```

src/Extractors/Po.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function fromString($string, Translations $translations = null, $f
3333
if ($line === '') {
3434
if ($translation->is('', '')) {
3535
self::parseHeaders($translation->getTranslation(), $translations);
36-
} else if ($translation->hasOriginal()) {
36+
} elseif ($translation->hasOriginal()) {
3737
$translations[] = $translation;
3838
}
3939

@@ -152,9 +152,9 @@ private static function isHeaderDefinition($line)
152152
/**
153153
* Parse the po headers
154154
*
155-
* @param string $headers
156-
* @param Translations $translations
157-
*
155+
* @param string $headers
156+
* @param Translations $translations
157+
*
158158
* @return boolean
159159
*/
160160
private static function parseHeaders($headers, Translations $translations)
@@ -164,7 +164,7 @@ private static function parseHeaders($headers, Translations $translations)
164164

165165
foreach ($headers as $line) {
166166
$line = self::clean($line);
167-
167+
168168
if (self::isHeaderDefinition($line)) {
169169
$header = array_map('trim', explode(':', $line, 2));
170170
$currentHeader = $header[0];

src/Translations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function deleteHeaders()
201201
}
202202

203203
/**
204-
* Removes one headers
204+
* Removes one header
205205
*
206206
* @param string $name
207207
*/

src/Utils/JsFunctionsScanner.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ public function getFunctions()
156156
return $functions;
157157
}
158158

159+
/**
160+
* Get the current context of the scan
161+
*
162+
* @param null|string $match To check whether the current status is this value
163+
*
164+
* @return string|boolean
165+
*/
159166
protected function status($match = null)
160167
{
161168
$status = isset($this->status[0]) ? $this->status[0] : null;
@@ -167,16 +174,33 @@ protected function status($match = null)
167174
return $status;
168175
}
169176

177+
/**
178+
* Add a new status to the stack
179+
*
180+
* @param string $status
181+
*/
170182
protected function downStatus($status)
171183
{
172184
array_unshift($this->status, $status);
173185
}
174186

187+
/**
188+
* Removes and return the current status
189+
*
190+
* @return string|null
191+
*/
175192
protected function upStatus()
176193
{
177194
return array_shift($this->status);
178195
}
179196

197+
/**
198+
* Prepares the arguments found in functions
199+
*
200+
* @param string $argument
201+
*
202+
* @return string
203+
*/
180204
protected static function prepareArgument($argument)
181205
{
182206
if ($argument && ($argument[0] === '"' || $argument[0] === "'")) {

src/Utils/Locales.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Locales
88

99
/**
1010
* Returns all languages data
11-
*
11+
*
1212
* @return array
1313
*/
1414
public static function getLanguages()
@@ -22,7 +22,7 @@ public static function getLanguages()
2222

2323
/**
2424
* Returns all territories data
25-
*
25+
*
2626
* @return array
2727
*/
2828
public static function getTerritories()

tests/LocalesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testPlurals()
2626
public function testLocalesVariants()
2727
{
2828
$translations = new Gettext\Translations();
29-
29+
3030
$translations->setLanguage('pt');
3131

3232
$pluralForms = $translations->getPluralForms();

0 commit comments

Comments
 (0)