Skip to content

Commit f551331

Browse files
committed
Initial commit 🍺
0 parents  commit f551331

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2475
-0
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.gitattributes export-ignore
2+
.gitignore export-ignore
3+
.php_cs.dist export-ignore
4+
.travis.yml export-ignore
5+
tests export-ignore

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
/vendor
3+
/.idea

.php_cs.dist

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__ . '/src')
5+
->in(__DIR__ . '/tests')
6+
;
7+
8+
return PhpCsFixer\Config::create()
9+
->setUsingCache(FALSE)
10+
->setIndent("\t")
11+
->setRules([
12+
'@PSR2' => TRUE,
13+
'array_syntax' => ['syntax' => 'short'],
14+
'trailing_comma_in_multiline_array' => true,
15+
'lowercase_constants' => FALSE,
16+
'declare_strict_types' => TRUE,
17+
'phpdoc_align' => TRUE,
18+
'blank_line_after_opening_tag' => TRUE,
19+
'blank_line_before_statement' => [
20+
'statements' => ['break', 'continue', 'declare', 'return'],
21+
],
22+
'blank_line_after_namespace' => TRUE,
23+
'single_blank_line_before_namespace' => TRUE,
24+
'return_type_declaration' => [
25+
'space_before' => 'none',
26+
],
27+
'ordered_imports' => [
28+
'sort_algorithm' => 'length',
29+
],
30+
'no_unused_imports' => TRUE,
31+
'single_line_after_imports' => TRUE,
32+
'no_leading_import_slash' => TRUE,
33+
])
34+
->setRiskyAllowed(TRUE)
35+
->setFinder($finder)
36+
;

.travis.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
language: php
2+
3+
php:
4+
- 7.1
5+
6+
env:
7+
- TESTER_PHP_BIN="php-cgi"
8+
9+
before_install:
10+
- composer self-update
11+
12+
install:
13+
- composer install --no-interaction --prefer-source
14+
15+
before_script:
16+
- travis_retry composer update
17+
- travis_retry composer create-project nette/code-checker temp/code-checker ~2.5 --no-interaction
18+
19+
script:
20+
# check coding standard for our code
21+
- vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run
22+
- vendor/bin/tester -p $TESTER_PHP_BIN -s ./tests # -c ./tests/php.ini
23+
- vendor/bin/tester ./tests --coverage coverage.xml --coverage-src ./src -d zend_extension=xdebug.so
24+
25+
after_failure:
26+
# print content of output files *.actual
27+
- for i in $(find ./tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
28+
29+
after_script:
30+
# get scrutinizer for coverage upload
31+
- wget https://scrutinizer-ci.com/ocular.phar
32+
- php ocular.phar code-coverage:upload --format=php-clover coverage.xml
33+
34+
cache:
35+
directories:
36+
- $HOME/.composer/cache

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MIT License
2+
3+
Copyright (c) 2019 '68 Publishers
4+
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in all
13+
> copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
> SOFTWARE.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# i18n
2+
3+
This package helps you to deal with regions with different languages, currencies and countries. It could be helpful even if you have single region project.
4+
5+
## Installation
6+
7+
The best way to install 68publishers/i18n is using Composer:
8+
9+
```bash
10+
composer require 68publishers/i18n
11+
```
12+
13+
then you can register extension into DIC:
14+
15+
```yaml
16+
extensions:
17+
i18n: SixtyEightPublishers\i18n\DI\I18nExtension
18+
```
19+
20+
## Configuration
21+
22+
```yaml
23+
environment:
24+
profile:
25+
europe:
26+
language: [ sk_SK, en_GB, de_DE, pl_PL ]
27+
currency: [ EUR, PLZ, GBP ]
28+
country: [ SK, GB, DE, PL ]
29+
domain: [ 'europe\.example\.com' ] # regex
30+
north_america:
31+
language: en_US
32+
currency: USD
33+
country: US
34+
domain: 'example\.com\/na'
35+
enabled: no # default is `yes`
36+
default: # If the default profile doesn't exists, the first profile is taken as default
37+
language: cs_CZ
38+
currency: CZK
39+
country: CZ
40+
41+
debugger: yes # adds Tracy panel, default is parameter %debugMode%
42+
translations:
43+
enabled: yes # enable integration with kdyby/translation, default is `no`
44+
use_default: yes # use language of default's profile if profile is not detected, default is `no`
45+
46+
# if you want to use custom profile storage or profile detector:
47+
storage: My\Custom\ProfileStorage
48+
detector: My\Custom\Detector
49+
```
50+
51+
### Integration with Kdyby\Translation
52+
53+
This feature provides automatic evaluation of the locale parameter for `kdyby\translation` based on profile settings in the extension.
54+
Default profile's language can be used if setting `translations.use_default` is set to `TRUE`.
55+
If is this setting set to `FALSE` default language will not be used and other resolvers will be invoked.
56+
Also if you change language via method `SixtyEightPublishers\i18n\Profile\ActiveProfile::changeLanguage()`, locale in Translator will be changed too.
57+
58+
## Contributing
59+
60+
Before committing any changes, don't forget to run
61+
62+
```bash
63+
vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run
64+
```
65+
66+
and
67+
68+
```bash
69+
vendor/bin/tester ./tests
70+
```

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "68publishers/i18n",
3+
"description": "Internationalization and localization your app with a minimum effort.",
4+
"keywords": ["68publishers", "i18n", "environment", "nette"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Vojtěch Lacina",
9+
"email": "[email protected]"
10+
},
11+
{
12+
"name": "Tomáš Glawaty",
13+
"email": "[email protected]"
14+
}
15+
],
16+
"require": {
17+
"php": "~7.1",
18+
"nette/di": "~2.4",
19+
"nette/http": "~2.4",
20+
"nette/utils": "~2.4"
21+
},
22+
"require-dev": {
23+
"friendsofphp/php-cs-fixer": "^2.0",
24+
"nette/tester": "^1.7",
25+
"mockery/mockery": "^1.2",
26+
"tracy/tracy": "^2.6",
27+
"kdyby/translation": "^2.6@dev"
28+
},
29+
"suggest": {
30+
"tracy/tracy": "For debugger panel integration.",
31+
"kdyby/translation": "For integration with Symfony Translator"
32+
},
33+
"autoload": {
34+
"classmap": ["src/"],
35+
"files": []
36+
},
37+
"autoload-dev": {
38+
"classmap": ["tests/"],
39+
"files": []
40+
}
41+
}

0 commit comments

Comments
 (0)