Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
parlote-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
parlote-facil
Validations
a2aff720
Valider
a2aff720
rédigé
11 years ago
par
Florian Staudacher
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
clear locale on each spec run, fix indentation
parent
1f98e1c6
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
app/assets/javascripts/helpers/i18n.js
+24
-16
24 ajouts, 16 suppressions
app/assets/javascripts/helpers/i18n.js
spec/javascripts/widgets/i18n-spec.js
+64
-49
64 ajouts, 49 suppressions
spec/javascripts/widgets/i18n-spec.js
avec
88 ajouts
et
65 suppressions
app/assets/javascripts/helpers/i18n.js
+
24
−
16
Voir le fichier @
a2aff720
...
...
@@ -2,20 +2,21 @@
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
Diaspora
.
I18n
=
{
language
:
"
en
"
,
locale
:
{},
loadLocale
:
function
(
locale
,
language
)
{
this
.
locale
=
$
.
extend
(
this
.
locale
,
locale
);
this
.
language
=
language
;
rule
=
this
.
t
(
'
pluralization_rule
'
);
if
(
rule
===
""
)
rule
=
'
function (n) { return n == 1 ? "one" : "other" }
'
;
eval
(
"
this.pluralizationKey =
"
+
rule
);
},
t
:
function
(
item
,
views
)
{
Diaspora
.
I18n
=
{
language
:
"
en
"
,
locale
:
{},
loadLocale
:
function
(
locale
,
language
)
{
this
.
locale
=
$
.
extend
(
this
.
locale
,
locale
);
this
.
language
=
language
;
rule
=
this
.
t
(
'
pluralization_rule
'
);
if
(
rule
===
""
)
rule
=
'
function (n) { return n == 1 ? "one" : "other" }
'
;
eval
(
"
this.pluralizationKey =
"
+
rule
);
},
t
:
function
(
item
,
views
)
{
var
items
=
item
.
split
(
"
.
"
),
translatedMessage
,
nextNamespace
;
...
...
@@ -35,5 +36,12 @@
}
return
_
.
template
(
translatedMessage
,
views
||
{});
}
};
},
reset
:
function
()
{
this
.
locale
=
{};
if
(
arguments
.
length
>
0
&&
!
(
_
.
isEmpty
(
arguments
[
0
]))
)
this
.
locale
=
arguments
[
0
];
}
};
Ce diff est replié.
Cliquez pour l'agrandir.
spec/javascripts/widgets/i18n-spec.js
+
64
−
49
Voir le fichier @
a2aff720
...
...
@@ -3,69 +3,84 @@
* the COPYRIGHT file.
*/
describe
(
"
Diaspora
"
,
function
()
{
describe
(
"
widgets
"
,
function
()
{
describe
(
"
i18n
"
,
function
()
{
var
locale
=
{
namespace
:
{
message
:
"
hey
"
,
template
:
"
<%= myVar %>
"
,
otherNamespace
:
{
message
:
"
hello from another namespace
"
,
otherMessage
:
{
zero
:
"
none
"
,
one
:
"
just one
"
,
few
:
"
just a few
"
,
many
:
"
way too many
"
,
other
:
"
what?
"
}
}
describe
(
"
Diaspora.I18n
"
,
function
()
{
var
locale
=
{
namespace
:
{
message
:
"
hey
"
,
template
:
"
<%= myVar %>
"
,
otherNamespace
:
{
message
:
"
hello from another namespace
"
,
otherMessage
:
{
zero
:
"
none
"
,
one
:
"
just one
"
,
few
:
"
just a few
"
,
many
:
"
way too many
"
,
other
:
"
what?
"
}
};
}
}
};
describe
(
"
loadLocale
"
,
function
()
{
it
(
"
se
ts th
e
cl
ass's
locale
variable
"
,
function
()
{
Diaspora
.
I18n
.
loadLocale
(
locale
);
beforeEach
(
function
(){
Diaspora
.
I18n
.
reset
();
// run tes
ts
wi
th cl
ean
locale
}
);
expect
(
Diaspora
.
I18n
.
locale
).
toEqual
(
locale
);
});
describe
(
"
::loadLocale
"
,
function
()
{
it
(
"
sets the class's locale variable
"
,
function
()
{
Diaspora
.
I18n
.
loadLocale
(
locale
);
it
(
"
extends the class's locale variable on multiple calls
"
,
function
()
{
var
data
=
{
another
:
'
section
'
},
extended
=
$
.
extend
(
locale
,
data
);
expect
(
Diaspora
.
I18n
.
locale
).
toEqual
(
locale
);
});
Diaspora
.
I18n
.
loadLocale
(
locale
);
Diaspora
.
I18n
.
loadLocale
(
data
);
it
(
"
extends the class's locale variable on multiple calls
"
,
function
()
{
var
data
=
{
another
:
'
section
'
},
extended
=
$
.
extend
(
locale
,
data
);
expect
(
Diaspora
.
I18n
.
locale
).
toEqual
(
extended
);
});
});
Diaspora
.
I18n
.
loadLocale
(
locale
);
Diaspora
.
I18n
.
loadLocale
(
data
);
describe
(
"
t
"
,
function
()
{
var
translation
;
beforeEach
(
function
()
{
Diaspora
.
I18n
.
loadLocale
(
locale
);
});
expect
(
Diaspora
.
I18n
.
locale
).
toEqual
(
extended
);
})
;
});
it
(
"
returns the specified translation
"
,
function
()
{
translation
=
Diaspora
.
I18n
.
t
(
"
namespace.message
"
);
describe
(
"
::t
"
,
function
()
{
var
translation
;
beforeEach
(
function
()
{
Diaspora
.
I18n
.
loadLocale
(
locale
);
});
expect
(
translation
).
toEqual
(
"
hey
"
);
}
);
it
(
"
returns the specified translation
"
,
function
()
{
translation
=
Diaspora
.
I18n
.
t
(
"
namespace.message
"
);
it
(
"
will go through a infinitely deep object
"
,
function
()
{
translation
=
Diaspora
.
I18n
.
t
(
"
namespace.otherNamespace.message
"
);
expect
(
translation
).
toEqual
(
"
hey
"
);
});
it
(
"
will go through a infinitely deep object
"
,
function
()
{
translation
=
Diaspora
.
I18n
.
t
(
"
namespace.otherNamespace.message
"
);
expect
(
translation
).
toEqual
(
"
hello from another namespace
"
);
});
expect
(
translation
).
toEqual
(
"
hello from another namespace
"
);
});
it
(
"
can render a mustache template
"
,
function
()
{
translation
=
Diaspora
.
I18n
.
t
(
"
namespace.template
"
,
{
myVar
:
"
it works!
"
});
it
(
"
can render a mustache template
"
,
function
()
{
translation
=
Diaspora
.
I18n
.
t
(
"
namespace.template
"
,
{
myVar
:
"
it works!
"
});
expect
(
translation
).
toEqual
(
"
it works!
"
);
});
expect
(
translation
).
toEqual
(
"
it works!
"
);
});
it
(
"
returns an empty string if the translation is not found
"
,
function
()
{
expect
(
Diaspora
.
I18n
.
t
(
"
missing.locale
"
)).
toEqual
(
""
);
});
});
describe
(
"
::reset
"
,
function
(){
it
(
"
clears the current locale
"
,
function
()
{
Diaspora
.
I18n
.
loadLocale
(
locale
);
Diaspora
.
I18n
.
reset
()
expect
(
Diaspora
.
I18n
.
locale
).
toEqual
({});
});
it
(
"
returns an empty string if the translation is not found
"
,
function
()
{
expect
(
Diaspora
.
I18n
.
t
(
"
missing.locale
"
)).
toEqual
(
""
);
});
});
it
(
"
sets the locale to only a specific value
"
,
function
()
{
var
data
=
{
some
:
'
value
'
};
Diaspora
.
I18n
.
loadLocale
(
locale
);
Diaspora
.
I18n
.
reset
(
data
);
expect
(
Diaspora
.
I18n
.
locale
).
toEqual
(
data
);
});
});
});
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter