Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
some update. language class completed
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Sep 20, 2017
1 parent ee50826 commit 1439593
Show file tree
Hide file tree
Showing 8 changed files with 916 additions and 385 deletions.
33 changes: 33 additions & 0 deletions examples/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Created by PhpStorm.
* User: inhere
* Date: 2017-09-20
* Time: 12:45
*/

use Sws\Memory\Language;

require dirname(__DIR__) . '/vendor/autoload.php';

$translator = new Language([
'basePath' => dirname(__DIR__) . '/resources/langs',
'langs' => ['en', 'zh-CN']
]);

$translator->scanAndLoad();

$translator['user.test'] = 'new value';

vd(
$translator['user.test'],
$translator->tl('user.test'),
$translator['zh-CN.user.test'],
$translator['keyNotExist'],
$translator['user.keyNotExist']
);

//vd($translator->all());

vd($translator->getLangData(null, false));
//vd($translator->getLangData('zh-CN', false));
11 changes: 11 additions & 0 deletions lib/sws/BaseSws.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ public static function lang()
return self::$app->get('lang');
}

/**
* @param string $key
* @param array $args
* @param null $lang
* @return array|string
*/
public static function tl($key, array $args = [], $lang = null)
{
return self::$app->get('lang')->tl($key, $args, $lang);
}

/*******************************************************************************
* request context
******************************************************************************/
Expand Down
Loading

0 comments on commit 1439593

Please sign in to comment.