Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(welcome-admin-cockpit): add message translation and i18n support #12

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions Gruntfile.js
Expand Up @@ -83,6 +83,18 @@ module.exports = function(grunt) {
sourceDir: pkg.gruntConfig.welcomeSourceDir,
buildTarget: pkg.gruntConfig.welcomeBuildTarget
});

require('./grunt/config/localescompile')(config, localesConf, {
appName: 'admin',
sourceDir: pkg.gruntConfig.adminSourceDir,
buildTarget: pkg.gruntConfig.adminBuildTarget
});

require('./grunt/config/localescompile')(config, localesConf, {
appName: 'cockpit',
sourceDir: pkg.gruntConfig.cockpitSourceDir,
buildTarget: pkg.gruntConfig.cockpitBuildTarget
});

var watchConf = {
commons_styles: {
Expand Down
36 changes: 25 additions & 11 deletions ui/admin/client/scripts/camunda-admin-ui.js
Expand Up @@ -20,6 +20,7 @@ module.exports = function(pluginDependencies) {
var ngDependencies = [
'ng',
'ngResource',
'pascalprecht.translate',
camCommonsUi.name,
directivesModule.name,
filtersModule.name,
Expand All @@ -32,6 +33,15 @@ module.exports = function(pluginDependencies) {

var appNgModule = angular.module(APP_NAME, ngDependencies);

function getUri(id) {
var uri = $('base').attr(id);
if (!id) {
throw new Error('Uri base for ' + id + ' could not be resolved');
}

return uri;
}

var ModuleConfig = [
'$routeProvider',
'UriProvider',
Expand All @@ -41,16 +51,6 @@ module.exports = function(pluginDependencies) {
) {
$routeProvider.otherwise({ redirectTo: '/' });


function getUri(id) {
var uri = $('base').attr(id);
if (!id) {
throw new Error('Uri base for ' + id + ' could not be resolved');
}

return uri;
}

UriProvider.replace(':appName', 'admin');
UriProvider.replace('app://', getUri('href'));
UriProvider.replace('cockpitbase://', getUri('app-root') + '/app/cockpit/');
Expand All @@ -70,16 +70,22 @@ module.exports = function(pluginDependencies) {
}]);
}];

appNgModule.provider('configuration', require('./../../../common/scripts/services/cam-configuration')(window.camAdminConf, 'Admin'));

appNgModule.config(ModuleConfig);

require('./../../../common/scripts/services/locales')(appNgModule, getUri('app-root'), 'admin');

appNgModule.controller('camAdminAppCtrl', [
'$scope',
'$route',
'camAPI',
'configuration',
function(
$scope,
$route,
camAPI
camAPI,
configuration
) {
var userService = camAPI.resource('user');
function getUserProfile(auth) {
Expand All @@ -105,6 +111,14 @@ module.exports = function(pluginDependencies) {
});

getUserProfile($scope.authentication);

$scope.langs = configuration.getAvailableLocales();
$scope.langCurrent = localStorage.getItem('lang_cam') || navigator.language
|| window.navigator.language || configuration.getFallbackLocale();
$scope.selectLang = function(langSelect) {
localStorage.setItem('lang_cam', langSelect);
location.reload();
};
}]);

if (typeof window.adminConf !== 'undefined' && window.adminConf.polyfills) {
Expand Down
5 changes: 5 additions & 0 deletions ui/admin/client/scripts/config.js
Expand Up @@ -13,4 +13,9 @@ window.camAdminConf = {
// 'custom-ui': 'custom-ui/scripts'
// }
// }

'locales': {
'availableLocales': ['es', 'en'],
'fallbackLocale': 'en'
}
};
29 changes: 24 additions & 5 deletions ui/admin/client/scripts/index.html
Expand Up @@ -57,36 +57,55 @@
authentication="authentication"
user-name="userFullName"
current-app="admin"
sign-out="{{ 'SIGN_OUT_ACTION' | translate }}"
my-profile="{{ 'MY_PROFILE' | translate }}"
brand-name="Camunda Admin"
ng-cloak>
<ul cam-if-logged-in
ng-controller="NavigationController">

<li ng-class="activeClass('#/user')">
<a href="#/users">Users</a>
<a href="#/users">{{ 'USERS_USERS' | translate }}</a>
</li>

<li ng-class="activeClass('#/group')">
<a href="#/groups">Groups</a>
<a href="#/groups">{{ 'GROUPS_GROUPS' | translate }}</a>
</li>

<li ng-class="activeClass('#/tenant')">
<a href="#/tenants">Tenants</a>
<a href="#/tenants">{{ 'TENANTS_TENANTS' | translate }}</a>
</li>

<li ng-class="activeClass('#/authorization')"
show-if-authorized
auth-permission="ALL"
auth-resource-name="authorization">
<a href="#/authorization?resource=0">Authorizations</a>
<a href="#/authorization?resource=0">{{ 'AUTHORIZATION_AUTHORIZATIONS' | translate }}</a>
</li>
<li ng-class="activeClass('#/system')"
show-if-authorized
auth-permission="ALL"
auth-resource-name="authorization">
<a href="#/system?section=system-settings-general">System</a>
<a href="#/system?section=system-settings-general">{{ 'SYSTEM_SYSTEM' | translate }}</a>
</li>
</ul>

<ul class="languages">
<li class="app-switch dropdown">
<a href
class="dropdown-toggle">
<span class="glyphicon glyphicon-flag"></span>
<span class="caret"></span>
</a>

<ul class="dropdown-menu dropdown-menu-right">
<li ng-repeat="lang in langs" ng-class="{active : lang === langCurrent}">
<a ng-click="selectLang(lang)">{{ lang }}</a>
</li>
</ul>
</li>
</ul>

</div>

<!-- content -->
Expand Down