]> khamidou — GitHub mirrors - electron.git/commitdiff
Add app.getLocale()
authorRyohei Ikegami <iofg2100@gmail.com>
Wed, 16 Sep 2015 08:16:21 +0000 (17:16 +0900)
committerRyohei Ikegami <iofg2100@gmail.com>
Wed, 16 Sep 2015 08:16:21 +0000 (17:16 +0900)
atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_app.h
spec/api-app-spec.coffee

index 43b3d82df109709883c07aea5428b1add725a699..2e7596971f485a821d5ab6d06b652a674ebaa139 100644 (file)
@@ -30,6 +30,7 @@
 #include "native_mate/dictionary.h"
 #include "native_mate/object_template_builder.h"
 #include "net/ssl/ssl_cert_request_info.h"
+#include "ui/base/l10n/l10n_util.h"
 
 #if defined(OS_WIN)
 #include "base/strings/utf_string_conversions.h"
@@ -248,6 +249,10 @@ void App::SetAppUserModelId(const std::string& app_id) {
 #endif
 }
 
+std::string App::GetLocale() {
+  return l10n_util::GetApplicationLocale("");
+}
+
 v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
   if (default_session_.IsEmpty())
     return v8::Null(isolate);
@@ -278,6 +283,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
       .SetMethod("getPath", &App::GetPath)
       .SetMethod("setDesktopName", &App::SetDesktopName)
       .SetMethod("setAppUserModelId", &App::SetAppUserModelId)
+      .SetMethod("getLocale", &App::GetLocale)
       .SetProperty("defaultSession", &App::DefaultSession);
 }
 
index 255f780e578df1619fd18f903c06c0d60793d9ad..4896a5f066a1da6173e005fc044ec0ed110eae1b 100644 (file)
@@ -65,6 +65,7 @@ class App : public mate::EventEmitter,
 
   void SetDesktopName(const std::string& desktop_name);
   void SetAppUserModelId(const std::string& app_id);
+  std::string GetLocale();
   v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate);
 
   v8::Global<v8::Value> default_session_;
index 38ef22ac80bd4d60238d2ea5e9f7d0547eb71aed..4b1a04e008271a91dc3217bba1724a03d4682fe2 100644 (file)
@@ -26,6 +26,10 @@ describe 'app module', ->
       assert.equal app.getName(), 'test-name'
       app.setName 'Electron Test'
 
+  describe 'app.getLocale()', ->
+    it 'should not be empty', ->
+      assert.notEqual app.getLocale(), ''
+
   describe 'BrowserWindow events', ->
     w = null
     afterEach ->