mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 07:27:04 +03:00
Added: support www.transifex.com
New format for translation files (yml) https://www.transifex.com/rainloop/rainloop-webmail/
This commit is contained in:
parent
acaeb82397
commit
5dcceaaca5
161 changed files with 24343 additions and 23386 deletions
|
|
@ -1859,7 +1859,7 @@ class Actions
|
|||
$oConfig->Get('login', 'determine_user_language', true))
|
||||
{
|
||||
$sLanguage = $this->ValidateLanguage(
|
||||
$this->detectUserLanguage(), $sLanguage, false);
|
||||
$this->detectUserLanguage($bAdmin), $sLanguage, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1876,10 +1876,10 @@ class Actions
|
|||
$aResult['Language'] = $this->ValidateLanguage($sLanguage, '', false);
|
||||
$aResult['LanguageAdmin'] = $this->ValidateLanguage($sLanguageAdmin, '', true);
|
||||
|
||||
$aResult['UserLanguageRaw'] = $this->detectUserLanguage();
|
||||
$aResult['UserLanguageRaw'] = $this->detectUserLanguage($bAdmin);
|
||||
|
||||
$aResult['UserLanguage'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', false, true, true);
|
||||
$aResult['UserLanguageAdmin'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', true, true, true);
|
||||
$aResult['UserLanguage'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', false, true);
|
||||
$aResult['UserLanguageAdmin'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', true, true);
|
||||
|
||||
$aResult['LangLink'] = './?/Lang/0/'.($bAdmin ? 'Admin' : 'App').'/'.
|
||||
($bAdmin ? $aResult['LanguageAdmin'] : $aResult['Language']).'/'.$sStaticCache.'/';
|
||||
|
|
@ -1901,27 +1901,45 @@ class Actions
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
private function getUserLanguageFromHeader()
|
||||
private function getUserLanguagesFromHeader()
|
||||
{
|
||||
$sLang = '';
|
||||
$sAcceptLang = $this->Http()->GetServer('HTTP_ACCEPT_LANGUAGE', 'en');
|
||||
if (false !== \strpos($sAcceptLang, ','))
|
||||
$aResult = $aList = array();
|
||||
$sAcceptLang = \strtolower($this->Http()->GetServer('HTTP_ACCEPT_LANGUAGE', 'en'));
|
||||
if (!empty($sAcceptLang) && \preg_match_all('/([a-z]{1,8}(?:-[a-z]{1,8})?)(?:;q=([0-9.]+))?/', $sAcceptLang, $aList))
|
||||
{
|
||||
$aParts = \explode(',', $sAcceptLang, 2);
|
||||
$sLang = empty($aParts[0]) ? '' : \trim(\strtolower($aParts[0]));
|
||||
$aResult = \array_combine($aList[1], $aList[2]);
|
||||
foreach ($aResult as $n => $v)
|
||||
{
|
||||
$aResult[$n] = $v ? $v : 1;
|
||||
}
|
||||
|
||||
\arsort($aResult, SORT_NUMERIC);
|
||||
}
|
||||
|
||||
return $sLang;
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function detectUserLanguage()
|
||||
public function detectUserLanguage($bAdmin = false)
|
||||
{
|
||||
return \preg_replace('/[^a-zA-Z0-9]+/', '-', $this->getUserLanguageFromHeader());
|
||||
$sResult = '';
|
||||
$aLangs = $this->getUserLanguagesFromHeader();
|
||||
|
||||
foreach (\array_keys($aLangs) as $sLang)
|
||||
{
|
||||
$sLang = $this->ValidateLanguage($sLang, '', $bAdmin, true);
|
||||
if (!empty($sLang))
|
||||
{
|
||||
$sResult = $sLang;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -8876,32 +8894,40 @@ class Actions
|
|||
* @param string $sLanguage
|
||||
* @param string $sDefault = ''
|
||||
* @param bool $bAdmin = false
|
||||
* @param bool $bSearchShortName = false
|
||||
* @param bool $bAllowEmptyResult = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ValidateLanguage($sLanguage, $sDefault = '', $bAdmin = false, $bSearchShortName = false, $bAllowEmptyResult = false)
|
||||
public function ValidateLanguage($sLanguage, $sDefault = '', $bAdmin = false, $bAllowEmptyResult = false)
|
||||
{
|
||||
$sResult = '';
|
||||
$aLang = $this->GetLanguages($bAdmin);
|
||||
|
||||
if (\is_array($aLang))
|
||||
{
|
||||
$aHelper = array('en' => 'en_us', 'ar' => 'ar_sa', 'cs' => 'cs_cz', 'no' => 'nb_no', 'ua' => 'uk_ua',
|
||||
'cn' => 'zh_cn', 'zh' => 'zh_cn', 'tw' => 'zh_tw');
|
||||
|
||||
$sLanguage = isset($aHelper[$sLanguage]) ? $aHelper[$sLanguage] : $sLanguage;
|
||||
$sDefault = isset($aHelper[$sDefault]) ? $aHelper[$sDefault] : $sDefault;
|
||||
|
||||
$sLanguage = \strtolower(\str_replace('-', '_', $sLanguage));
|
||||
if (2 === strlen($sLanguage))
|
||||
{
|
||||
$sLanguage = $sLanguage.'_'.$sLanguage;
|
||||
}
|
||||
|
||||
$sDefault = \strtolower(\str_replace('-', '_', $sDefault));
|
||||
if (2 === strlen($sDefault))
|
||||
{
|
||||
$sDefault = $sDefault.'_'.$sDefault;
|
||||
}
|
||||
|
||||
if (\in_array($sLanguage, $aLang))
|
||||
{
|
||||
$sResult = $sLanguage;
|
||||
}
|
||||
|
||||
if ($bSearchShortName && empty($sResult) && 2 < \strlen($sLanguage))
|
||||
{
|
||||
$sLanguage = \substr($sLanguage, 0, 2);
|
||||
if (\in_array($sLanguage, $aLang))
|
||||
{
|
||||
$sResult = $sLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($sResult) && !empty($sDefault) && \in_array($sDefault, $aLang))
|
||||
{
|
||||
$sResult = $sDefault;
|
||||
|
|
@ -8909,8 +8935,8 @@ class Actions
|
|||
|
||||
if (empty($sResult) && !$bAllowEmptyResult)
|
||||
{
|
||||
$sResult = $this->Config()->Get('webmail', $bAdmin ? 'language_admin' : 'language', 'en');
|
||||
$sResult = \in_array($sResult, $aLang) ? $sResult : 'en';
|
||||
$sResult = $this->Config()->Get('webmail', $bAdmin ? 'language_admin' : 'language', 'en_us');
|
||||
$sResult = \in_array($sResult, $aLang) ? $sResult : 'en_us';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -9018,20 +9044,13 @@ class Actions
|
|||
public function GetLanguages($bAdmin = false)
|
||||
{
|
||||
static $aCache = array();
|
||||
$sDir = APP_VERSION_ROOT_PATH.'langs/'.($bAdmin ? 'admin/' : '');
|
||||
$sDir = APP_VERSION_ROOT_PATH.'app/localization/'.($bAdmin ? 'admin' : 'webmail').'/';
|
||||
|
||||
if (isset($aCache[$sDir]))
|
||||
{
|
||||
return $aCache[$sDir];
|
||||
}
|
||||
|
||||
// $aTopper = array('en');
|
||||
// $sUserLanguage = $this->detectUserLanguage();
|
||||
// if (!empty($sUserLanguage) && 'en' !== $sUserLanguage)
|
||||
// {
|
||||
// $aTopper[] = $sUserLanguage;
|
||||
// }
|
||||
|
||||
$aTop = array();
|
||||
$aList = array();
|
||||
|
||||
|
|
@ -9042,19 +9061,12 @@ class Actions
|
|||
{
|
||||
while (($sFile = \readdir($rDirH)) !== false)
|
||||
{
|
||||
if ('.' !== $sFile{0} && \is_file($sDir.'/'.$sFile) && '.ini' === \substr($sFile, -4))
|
||||
if ('.' !== $sFile{0} && \is_file($sDir.'/'.$sFile) && '.yml' === \substr($sFile, -4))
|
||||
{
|
||||
$sLang = \strtolower(\substr($sFile, 0, -4));
|
||||
if (0 < \strlen($sLang) && 'always' !== $sLang)
|
||||
if (0 < \strlen($sLang) && 'always' !== $sLang && '_source.en' !== $sLang)
|
||||
{
|
||||
// if (\in_array(\substr($sLang, 0, 2), $aTopper))
|
||||
// {
|
||||
// \array_push($aTop, $sLang);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
\array_push($aList, $sLang);
|
||||
// }
|
||||
\array_push($aList, $sLang);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9470,8 +9482,10 @@ class Actions
|
|||
if (null === $aLang)
|
||||
{
|
||||
$aLang = array();
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'app/i18n/langs.ini', $aLang);
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'langs/'.$sLang.'.ini', $aLang);
|
||||
// \RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'app/i18n/langs.ini', $aLang);
|
||||
// \RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'langs/'.$sLang.'.ini', $aLang);
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'app/localization/langs.yml', $aLang);
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'app/localization/webmail/'.$sLang.'.ini', $aLang);
|
||||
|
||||
$this->Plugins()->ReadLang($sLang, $aLang);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -831,7 +831,7 @@ class ServiceActions
|
|||
'{{BaseWebStaticPath}}' => \RainLoop\Utils::WebStaticPath(),
|
||||
'{{ErrorTitle}}' => $sTitle,
|
||||
'{{ErrorHeader}}' => $sTitle,
|
||||
'{{ErrorDesc}}' => $sDesc
|
||||
'{{ErrorDesc}}' => $sDesc.':'
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -1248,20 +1248,10 @@ class ServiceActions
|
|||
*/
|
||||
private function convertLanguageNameToMomentLanguageName($sLanguage)
|
||||
{
|
||||
switch ($sLanguage)
|
||||
{
|
||||
case 'pt-pt':
|
||||
$sLanguage = 'pt';
|
||||
break;
|
||||
case 'ja-jp':
|
||||
$sLanguage = 'ja';
|
||||
break;
|
||||
case 'ko-kr':
|
||||
$sLanguage = 'ko';
|
||||
break;
|
||||
}
|
||||
$aHelper = array('en_gb' => 'en-gb', 'fr_ca' => 'fr-ca', 'pt_br' => 'pt-br',
|
||||
'uk_ua' => 'ua', 'zh_cn' => 'zh-cn', 'zh_tw' => 'zh-tw');
|
||||
|
||||
return $sLanguage;
|
||||
return isset($aHelper[$sLanguage]) ? $aHelper[$sLanguage] : \substr($sLanguage, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1276,7 +1266,7 @@ class ServiceActions
|
|||
$aResultLang = array();
|
||||
|
||||
$sMoment = 'window.moment && window.moment.lang && window.moment.lang(\'en\');';
|
||||
$sMomentFileName = APP_VERSION_ROOT_PATH.'app/i18n/moment/'.
|
||||
$sMomentFileName = APP_VERSION_ROOT_PATH.'app/localization/moment/'.
|
||||
$this->convertLanguageNameToMomentLanguageName($sLanguage).'.js';
|
||||
|
||||
if (\file_exists($sMomentFileName))
|
||||
|
|
@ -1285,9 +1275,15 @@ class ServiceActions
|
|||
$sMoment = \preg_replace('/\/\/[^\n]+\n/', '', $sMoment);
|
||||
}
|
||||
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'app/i18n/langs.ini', $aResultLang);
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'langs/'.
|
||||
($bAdmin ? 'admin/' : '').$sLanguage.'.ini', $aResultLang);
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'app/localization/langs.yml', $aResultLang);
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'app/localization/'.
|
||||
($bAdmin ? 'admin' : 'webmail').'/_source.en.yml', $aResultLang);
|
||||
|
||||
if ('en_US' !== $sLanguage)
|
||||
{
|
||||
\RainLoop\Utils::ReadAndAddLang(APP_VERSION_ROOT_PATH.'app/localization/'.
|
||||
($bAdmin ? 'admin' : 'webmail').'/'.$sLanguage.'.yml', $aResultLang);
|
||||
}
|
||||
|
||||
$this->Plugins()->ReadLang($sLanguage, $aResultLang);
|
||||
|
||||
|
|
|
|||
|
|
@ -389,7 +389,29 @@ class Utils
|
|||
{
|
||||
if (\file_exists($sFileName))
|
||||
{
|
||||
$aLang = \RainLoop\Utils::CustomParseIniFile($sFileName, true);
|
||||
$isYml = '.yml' === substr($sFileName, -4);
|
||||
if ($isYml)
|
||||
{
|
||||
$aLang = \spyc_load(\str_replace(array(': >-', ': |-'), array(': >', ': |'), \file_get_contents($sFileName)));
|
||||
if (\is_array($aLang))
|
||||
{
|
||||
\reset($aLang);
|
||||
$sLangKey = key($aLang);
|
||||
if (isset($aLang[$sLangKey]) && is_array($aLang[$sLangKey]))
|
||||
{
|
||||
$aLang = $aLang[$sLangKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
$aLang = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$aLang = \RainLoop\Utils::CustomParseIniFile($sFileName, true);
|
||||
}
|
||||
|
||||
if (\is_array($aLang))
|
||||
{
|
||||
foreach ($aLang as $sKey => $mValue)
|
||||
|
|
|
|||
21
rainloop/v/0.0.0/app/libraries/spyc/COPYING
Normal file
21
rainloop/v/0.0.0/app/libraries/spyc/COPYING
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License
|
||||
|
||||
Copyright (c) 2011 Vladimir Andersen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
30
rainloop/v/0.0.0/app/libraries/spyc/README.md
Normal file
30
rainloop/v/0.0.0/app/libraries/spyc/README.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
**Spyc** is a YAML loader/dumper written in pure PHP. Given a YAML document, Spyc will return an array that
|
||||
you can use however you see fit. Given an array, Spyc will return a string which contains a YAML document
|
||||
built from your data.
|
||||
|
||||
**YAML** is an amazingly human friendly and strikingly versatile data serialization language which can be used
|
||||
for log files, config files, custom protocols, the works. For more information, see http://www.yaml.org.
|
||||
|
||||
Spyc supports YAML 1.0 specification.
|
||||
|
||||
## Using Spyc
|
||||
|
||||
Using Spyc is trivial:
|
||||
|
||||
```
|
||||
<?php
|
||||
require_once "spyc.php";
|
||||
$Data = Spyc::YAMLLoad('spyc.yaml');
|
||||
```
|
||||
|
||||
or (if you prefer functional syntax)
|
||||
|
||||
```
|
||||
<?php
|
||||
require_once "spyc.php";
|
||||
$Data = spyc_load_file('spyc.yaml');
|
||||
```
|
||||
|
||||
## Donations, anyone?
|
||||
|
||||
If you find Spyc useful, I'm accepting Bitcoin donations (who doesn't these days?) at 193bEkLP7zMrNLZm9UdUet4puGD5mQiLai
|
||||
1155
rainloop/v/0.0.0/app/libraries/spyc/Spyc.php
Normal file
1155
rainloop/v/0.0.0/app/libraries/spyc/Spyc.php
Normal file
File diff suppressed because it is too large
Load diff
30
rainloop/v/0.0.0/app/libraries/spyc/composer.json
Normal file
30
rainloop/v/0.0.0/app/libraries/spyc/composer.json
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "mustangostang/spyc",
|
||||
"description": "A simple YAML loader/dumper class for PHP",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"spyc",
|
||||
"yaml",
|
||||
"yml"
|
||||
],
|
||||
"homepage": "https://github.com/mustangostang/spyc/",
|
||||
"authors" : [{
|
||||
"name": "mustangostang",
|
||||
"email": "vlad.andersen@gmail.com"
|
||||
}],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3.1"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [ "Spyc.php" ]
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.3.*@dev"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.5.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue