Skip to content

Commit

Permalink
Merge pull request #2244 from JasonBarnabe/categoryl10n
Browse files Browse the repository at this point in the history
Translatable category names
  • Loading branch information
tburry committed Jan 16, 2015
2 parents 600fcf7 + 894fbb9 commit f476a47
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions applications/vanilla/models/class.categorymodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,13 @@ public static function JoinUserData(&$Categories, $AddUserCategory = TRUE) {
$Categories[$CID]['PermsDiscussionsEdit'] = $Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $Category['PermissionCategoryID']);
$Categories[$CID]['PermsCommentsAdd'] = $Session->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $Category['PermissionCategoryID']);
}

// Translate name and description
foreach ($IDs as $ID) {
$Code = $Categories[$ID]['UrlCode'];
$Categories[$ID]['Name'] = TranslateContent("Categories.".$Code.".Name", $Categories[$ID]['Name']);
$Categories[$ID]['Description'] = TranslateContent("Categories.".$Code.".Description", $Categories[$ID]['Description']);
}
}

/**
Expand Down
16 changes: 16 additions & 0 deletions library/core/functions.general.php
Original file line number Diff line number Diff line change
Expand Up @@ -3270,6 +3270,22 @@ function T($Code, $Default = FALSE) {
}
}

if (!function_exists('TranslateContent')) {
/**
* Translates user-generated content into the selected locale's definition. Currently just an
* alias for T().
*
* @param string $Code The code related to the language-specific definition.
* Codes thst begin with an '@' symbol are treated as literals and not translated.
* @param string $Default The default value to be displayed if the translation code is not found.
* @return string The translated string or $Code if there is no value in $Default.
* @see Gdn::Translate()
*/
function TranslateContent($Code, $Default = FALSE) {
return T($Code, $Default);
}
}

if (!function_exists('Theme')) {
function Theme() {
return Gdn::ThemeManager()->CurrentTheme();
Expand Down

0 comments on commit f476a47

Please sign in to comment.