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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
f57c38df
Commit
f57c38df
authored
11 years ago
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #6431 from owncloud/core-pluraltranslationsfix
Added plural translation fallback
parents
5f4b32c3
d8d11e39
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
core/js/js.js
+8
-4
8 additions, 4 deletions
core/js/js.js
with
8 additions
and
4 deletions
core/js/js.js
+
8
−
4
View file @
f57c38df
...
@@ -48,8 +48,8 @@ function initL10N(app) {
...
@@ -48,8 +48,8 @@ function initL10N(app) {
t
.
cache
[
app
]
=
[];
t
.
cache
[
app
]
=
[];
}
}
}
}
if
(
typeof
t
.
plural_function
==
'
undefined
'
)
{
if
(
typeof
t
.
plural_function
[
app
]
==
'
undefined
'
)
{
t
.
plural_function
=
function
(
n
)
{
t
.
plural_function
[
app
]
=
function
(
n
)
{
var
p
=
(
n
!=
1
)
?
1
:
0
;
var
p
=
(
n
!=
1
)
?
1
:
0
;
return
{
'
nplural
'
:
2
,
'
plural
'
:
p
};
return
{
'
nplural
'
:
2
,
'
plural
'
:
p
};
};
};
...
@@ -74,7 +74,7 @@ function initL10N(app) {
...
@@ -74,7 +74,7 @@ function initL10N(app) {
Gettext._locale_data[domain].head.plural_func = eval("("+code+")");
Gettext._locale_data[domain].head.plural_func = eval("("+code+")");
*/
*/
var
code
=
'
var plural; var nplurals;
'
+
pf
+
'
return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };
'
;
var
code
=
'
var plural; var nplurals;
'
+
pf
+
'
return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };
'
;
t
.
plural_function
=
new
Function
(
"
n
"
,
code
);
t
.
plural_function
[
app
]
=
new
Function
(
"
n
"
,
code
);
}
else
{
}
else
{
console
.
log
(
"
Syntax error in language file. Plural-Forms header is invalid [
"
+
t
.
plural_forms
+
"
]
"
);
console
.
log
(
"
Syntax error in language file. Plural-Forms header is invalid [
"
+
t
.
plural_forms
+
"
]
"
);
}
}
...
@@ -110,6 +110,10 @@ function t(app, text, vars, count){
...
@@ -110,6 +110,10 @@ function t(app, text, vars, count){
}
}
}
}
t
.
cache
=
{};
t
.
cache
=
{};
// different apps might or might not redefine the nplurals function correctly
// this is to make sure that a "broken" app doesn't mess up with the
// other app's plural function
t
.
plural_function
=
{};
/**
/**
* translate a string
* translate a string
...
@@ -126,7 +130,7 @@ function n(app, text_singular, text_plural, count, vars) {
...
@@ -126,7 +130,7 @@ function n(app, text_singular, text_plural, count, vars) {
if
(
typeof
(
t
.
cache
[
app
][
identifier
]
)
!==
'
undefined
'
){
if
(
typeof
(
t
.
cache
[
app
][
identifier
]
)
!==
'
undefined
'
){
var
translation
=
t
.
cache
[
app
][
identifier
];
var
translation
=
t
.
cache
[
app
][
identifier
];
if
(
$
.
isArray
(
translation
))
{
if
(
$
.
isArray
(
translation
))
{
var
plural
=
t
.
plural_function
(
count
);
var
plural
=
t
.
plural_function
[
app
]
(
count
);
return
t
(
app
,
translation
[
plural
.
plural
],
vars
,
count
);
return
t
(
app
,
translation
[
plural
.
plural
],
vars
,
count
);
}
}
}
}
...
...
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