aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/template/functions.php16
-rw-r--r--lib/private/util.php22
2 files changed, 36 insertions, 2 deletions
diff --git a/lib/private/template/functions.php b/lib/private/template/functions.php
index cbe751e59b5..8c94b7cf345 100644
--- a/lib/private/template/functions.php
+++ b/lib/private/template/functions.php
@@ -56,6 +56,22 @@ function style($app, $file) {
}
/**
+ * Shortcut for adding translations to a page
+ * @param string $app the appname
+ * @param string|string[] $file the filename,
+ * if an array is given it will add all styles
+ */
+function translation($app, $file) {
+ if(is_array($file)) {
+ foreach($file as $f) {
+ OC_Util::addStyle($app, $f);
+ }
+ } else {
+ OC_Util::addStyle($app, $file);
+ }
+}
+
+/**
* Shortcut for HTML imports
* @param string $app the appname
* @param string|string[] $file the path relative to the app's component folder,
diff --git a/lib/private/util.php b/lib/private/util.php
index 6cd982c222e..5105bb22931 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -333,7 +333,7 @@ class OC_Util {
/**
* add a javascript file
*
- * @param string $application
+ * @param string $application application id
* @param string|null $file filename
* @return void
*/
@@ -350,9 +350,27 @@ class OC_Util {
}
/**
+ * add a translation JS file
+ *
+ * @param string $application application id
+ * @param string $languageCode language code, defaults to the current language
+ */
+ public static function addTranslations($application, $languageCode = null) {
+ if (is_null($languageCode)) {
+ $l = new \OC_L10N($application);
+ $languageCode = $l->getLanguageCode($application);
+ }
+ if (!empty($application)) {
+ self::$scripts[] = "$application/l10n/$languageCode";
+ } else {
+ self::$scripts[] = "js/$languageCode";
+ }
+ }
+
+ /**
* add a css file
*
- * @param string $application
+ * @param string $application application id
* @param string|null $file filename
* @return void
*/