Add app.getLocale()

This commit is contained in:
Ryohei Ikegami 2015-09-16 17:16:21 +09:00
parent 08f5c32306
commit b9c274929b
3 changed files with 11 additions and 0 deletions

View file

@ -30,6 +30,7 @@
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h" #include "native_mate/object_template_builder.h"
#include "net/ssl/ssl_cert_request_info.h" #include "net/ssl/ssl_cert_request_info.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
@ -248,6 +249,10 @@ void App::SetAppUserModelId(const std::string& app_id) {
#endif #endif
} }
std::string App::GetLocale() {
return l10n_util::GetApplicationLocale("");
}
v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) { v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
if (default_session_.IsEmpty()) if (default_session_.IsEmpty())
return v8::Null(isolate); return v8::Null(isolate);
@ -278,6 +283,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
.SetMethod("getPath", &App::GetPath) .SetMethod("getPath", &App::GetPath)
.SetMethod("setDesktopName", &App::SetDesktopName) .SetMethod("setDesktopName", &App::SetDesktopName)
.SetMethod("setAppUserModelId", &App::SetAppUserModelId) .SetMethod("setAppUserModelId", &App::SetAppUserModelId)
.SetMethod("getLocale", &App::GetLocale)
.SetProperty("defaultSession", &App::DefaultSession); .SetProperty("defaultSession", &App::DefaultSession);
} }

View file

@ -65,6 +65,7 @@ class App : public mate::EventEmitter,
void SetDesktopName(const std::string& desktop_name); void SetDesktopName(const std::string& desktop_name);
void SetAppUserModelId(const std::string& app_id); void SetAppUserModelId(const std::string& app_id);
std::string GetLocale();
v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate); v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate);
v8::Global<v8::Value> default_session_; v8::Global<v8::Value> default_session_;

View file

@ -26,6 +26,10 @@ describe 'app module', ->
assert.equal app.getName(), 'test-name' assert.equal app.getName(), 'test-name'
app.setName 'Electron Test' app.setName 'Electron Test'
describe 'app.getLocale()', ->
it 'should not be empty', ->
assert.notEqual app.getLocale(), ''
describe 'BrowserWindow events', -> describe 'BrowserWindow events', ->
w = null w = null
afterEach -> afterEach ->