Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
35a42da3
Commit
35a42da3
authored
11 years ago
by
Thomas Müller
Browse files
Options
Downloads
Patches
Plain Diff
PHPDoc comments adjusted *partially* - fixing call to createPluralFormFunction
parent
389d0824
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/l10n.php
+18
-11
18 additions, 11 deletions
lib/l10n.php
with
18 additions
and
11 deletions
lib/l10n.php
+
18
−
11
View file @
35a42da3
...
...
@@ -2,8 +2,10 @@
/**
* ownCloud
*
* @author Frank Karlitschek
* @author Jakob Sack
* @copyright 2012 Frank Karlitschek frank@owncloud.org
* @copyright 2013 Jakob Sack
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
...
...
@@ -76,6 +78,8 @@ class OC_L10N{
/**
* get an L10N instance
* @param $app string
* @param $lang string|null
* @return OC_L10N
*/
public
static
function
get
(
$app
,
$lang
=
null
)
{
...
...
@@ -91,8 +95,8 @@ class OC_L10N{
/**
* @brief The constructor
* @param $app
the
app requesting l10n
* @param $lang default: null Language
* @param $app
string
app requesting l10n
* @param $lang
string
default: null Language
* @returns OC_L10N-Object
*
* If language is not set, the constructor tries to find the right
...
...
@@ -168,15 +172,14 @@ class OC_L10N{
/**
* @brief Creates a function that The constructor
* @param $app the app requesting l10n
* @param $lang default: null Language
* @returns OC_L10N-Object
*
* If language is not set, the constructor tries to find the right
* language.
*
* Parts of the code is copied from Habari:
* https://github.com/habari/system/blob/master/classes/locale.php
* @param $string string
* @return string
*/
protected
function
createPluralFormFunction
(
$string
){
if
(
preg_match
(
'/^\s*nplurals\s*=\s*(\d+)\s*;\s*plural=(.*)$/u'
,
$string
,
$matches
))
{
...
...
@@ -190,7 +193,7 @@ class OC_L10N{
'nplurals='
.
$nplurals
.
'; plural='
.
$plural
);
// add parens
// add paren
t
s
// important since PHP's ternary evaluates from left to right
$body
.
=
';'
;
$res
=
''
;
...
...
@@ -305,7 +308,7 @@ class OC_L10N{
/**
* @brief getPluralFormString
* @returns
Fetches
the gettext "Plural-Forms"-string
* @returns
string containing
the gettext "Plural-Forms"-string
*
* Returns a string like "nplurals=2; plural=(n != 1);"
*/
...
...
@@ -316,14 +319,14 @@ class OC_L10N{
/**
* @brief getPluralFormFunction
* @returns
returns
the plural form function
* @returns
string
the plural form function
*
* returned function accepts the argument $n
*/
public
function
getPluralFormFunction
()
{
$this
->
init
();
if
(
is_null
(
$this
->
plural_form_function
))
{
$this
->
plural_form_function
=
createPluralFormFunction
(
$this
->
plural_form_string
);
$this
->
plural_form_function
=
$this
->
createPluralFormFunction
(
$this
->
plural_form_string
);
}
return
$this
->
plural_form_function
;
}
...
...
@@ -369,8 +372,12 @@ class OC_L10N{
case
'date'
:
case
'datetime'
:
case
'time'
:
if
(
$data
instanceof
DateTime
)
return
$data
->
format
(
$this
->
localizations
[
$type
]);
elseif
(
is_string
(
$data
))
$data
=
strtotime
(
$data
);
if
(
$data
instanceof
DateTime
)
{
return
$data
->
format
(
$this
->
localizations
[
$type
]);
}
elseif
(
is_string
(
$data
))
{
$data
=
strtotime
(
$data
);
}
$locales
=
array
(
self
::
findLanguage
());
if
(
strlen
(
$locales
[
0
])
==
2
)
{
$locales
[]
=
$locales
[
0
]
.
'_'
.
strtoupper
(
$locales
[
0
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment