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

chore(languages): implement a LanguageService #173

Merged

Conversation

jniles
Copy link
Collaborator

@jniles jniles commented Mar 7, 2016

This commit implements a LanguageService, responsible to managing the
languages and locales throughout the application. In order to do this,
several changes have been made:

  1. The database language table now contains the locales for
    angular-moment and tmhDynamicLocale. This requires a database rebuild.
  2. Three controllers responsible for languages now use LanguageService.
    These are:
    1. ApplicationController
    2. LoginController
    3. SettingsController

USAGE
If you want to use the LanguageService to display or set languages from
a controller, the API is quite simple. Languages are loaded from the
database on startup, and can be accessed via the read() function as
shown below.

angular.module('bhima.controllers')
.controller('SomeController', [ 'LanguageService', function (Languages) {
  var vm = this;

  // reading languages from the service
  Languages.read()
  .then(function (languages) {
    vm.languages = languages;
  });

  // setting the application language based on a locale key
  Languages.set(key);

  // get the current language
  var languageKey = Languages.get();
}]);

Closes #160.

@@ -2,11 +2,11 @@ angular.module('bhima.controllers')
.controller('LoginController', LoginController);

LoginController.$inject = [
'$scope', '$translate', '$location', '$http', '$timeout', 'appcache', 'appstate', 'SessionService',
'$scope', '$location', '$http', '$timeout', 'appcache', 'appstate', 'SessionService', 'LanguageService',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need a comma after LanguageService

@jniles
Copy link
Collaborator Author

jniles commented Mar 9, 2016

@DedrickEnc, your comments have been fixed. Let me know if there is anything else that needs addressing.

@jniles jniles force-pushed the feature-language-service branch 2 times, most recently from 02cf926 to 4bd889b Compare March 9, 2016 11:08
This commit implements a LanguageService, responsible to managing the
languages and locales throughout the application. In order to do this,
several changes have been made:
 1. The database `language` table now contains the locales for
 angular-moment and tmhDynamicLocale.  This requires a database rebuild.
 2. Three controllers responsible for languages now use LanguageService.
 These are:
   1. ApplicationController
   2. LoginController
   3. SettingsController

USAGE
If you want to use the LanguageService to display or set languages from
a controller, the API is quite simple.  Languages are loaded from the
database on startup, and can be accessed via the `read()` function as
shown below.

```js
angular.module('bhima.controllers')
.controller('SomeController', [ 'LanguageService', function (Languages) {
  var vm = this;

  // reading languages from the service
  Languages.read()
  .then(function (languages) {
    vm.languages = languages;
  });

  // setting the application language based on a locale key
  Languages.set(key);

  // get the current language
  var languageKey = Langauges.get();
}]);
```

Closes #160.
@jniles
Copy link
Collaborator Author

jniles commented Mar 9, 2016

@DedrickEnc , updated with the important changes you suggested.

@DedrickEnc
Copy link
Contributor

As soon as all tests passed, it will be merged.

DedrickEnc added a commit that referenced this pull request Mar 9, 2016
chore(languages): implement a LanguageService
@DedrickEnc DedrickEnc merged commit e6d44cd into Third-Culture-Software:master Mar 9, 2016
@jniles jniles deleted the feature-language-service branch March 9, 2016 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants