diff --git a/.eslintcache b/.eslintcache index 44575a01..90a99a47 100644 --- a/.eslintcache +++ b/.eslintcache @@ -1 +1 @@ -[{"/Users/pveiga/repos/wisemapping-react/src/Footer.js":"1","/Users/pveiga/repos/wisemapping-react/src/Header.js":"2","/Users/pveiga/repos/wisemapping-react/src/index.js":"3","/Users/pveiga/repos/wisemapping-react/src/LoginPage.js":"4"},{"size":1747,"mtime":1606529689598,"results":"5","hashOfConfig":"6"},{"size":1557,"mtime":1606529996629,"results":"7","hashOfConfig":"6"},{"size":531,"mtime":1606582877518,"results":"8","hashOfConfig":"6"},{"size":4184,"mtime":1606583450721,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1xegajf",{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"16","messages":"17","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/pveiga/repos/wisemapping-react/src/Footer.js",[],"/Users/pveiga/repos/wisemapping-react/src/Header.js",[],"/Users/pveiga/repos/wisemapping-react/src/index.js",[],"/Users/pveiga/repos/wisemapping-react/src/LoginPage.js",["18"],{"ruleId":"19","severity":1,"message":"20","line":7,"column":7,"nodeType":"21","messageId":"22","endLine":7,"endColumn":26},"no-unused-vars","'ConfigStatusMessage' is defined but never used.","Identifier","unusedVar"] \ No newline at end of file +[{"/Users/pveiga/repos/wisemapping-react/src/Footer.js":"1","/Users/pveiga/repos/wisemapping-react/src/Header.js":"2","/Users/pveiga/repos/wisemapping-react/src/index.js":"3","/Users/pveiga/repos/wisemapping-react/src/LoginPage.js":"4"},{"size":1747,"mtime":1606529689598,"results":"5","hashOfConfig":"6"},{"size":1557,"mtime":1606529996629,"results":"7","hashOfConfig":"6"},{"size":702,"mtime":1606586450512,"results":"8","hashOfConfig":"6"},{"size":4283,"mtime":1606584003214,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1xegajf",{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"16","messages":"17","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/pveiga/repos/wisemapping-react/src/Footer.js",[],"/Users/pveiga/repos/wisemapping-react/src/Header.js",[],"/Users/pveiga/repos/wisemapping-react/src/index.js",[],"/Users/pveiga/repos/wisemapping-react/src/LoginPage.js",["18"],{"ruleId":"19","severity":1,"message":"20","line":7,"column":7,"nodeType":"21","messageId":"22","endLine":7,"endColumn":26},"no-unused-vars","'ConfigStatusMessage' is defined but never used.","Identifier","unusedVar"] \ No newline at end of file diff --git a/README.md b/README.md index a3d7125e..1ee14da0 100644 --- a/README.md +++ b/README.md @@ -71,4 +71,9 @@ This section has moved here: [https://facebook.github.io/create-react-app/docs/t # Generate I18n resource -npm run extract -- 'src/*.js' --out-file src/lang/en.json +## Extract +npm run extract -- 'src/*.js' --out-file lang/en.json + +## Compile +npm run compile -- lang/en.json --ast --out-file src/compiled-lang/en.json +npm run compile -- lang/es.json --ast --out-file src/compiled-lang/es.json diff --git a/lang/en.json b/lang/en.json new file mode 100644 index 00000000..6e4e9b9b --- /dev/null +++ b/lang/en.json @@ -0,0 +1,63 @@ +{ + "ABOUT_US": { + "defaultMessage": "About Us" + }, + "CONTACT_US": { + "defaultMessage": "Contact Us" + }, + "DONATIONS": { + "defaultMessage": "PayPal Donations" + }, + "DONT_HAVE_ACCOUNT": { + "defaultMessage": "Don't have an account ?" + }, + "EMAIL": { + "defaultMessage": "Email" + }, + "FAQ": { + "defaultMessage": "F.A.Q." + }, + "FEEDBACK": { + "defaultMessage": "Feedback" + }, + "FORGOT_PASSWORD": { + "defaultMessage": "Forgot Password ?" + }, + "LOGIN_ERROR": { + "defaultMessage": "The email address or password you entered is not valid." + }, + "LOG_INTO": { + "defaultMessage": "Log Into Your Account" + }, + "NO_PRODUCTION_DATABASE_CONFIGURED": { + "defaultMessage": "Warning: Although HSQLDB is bundled with WiseMapping by default during the installation, we do not recommend this database for production use. Please consider using MySQL 5.7 instead. You can find more information how to configure MySQL", + "description": "Missing production database configured" + }, + "OPEN_SOURCE": { + "defaultMessage": "Open Source" + }, + "PASSWORD": { + "defaultMessage": "Password" + }, + "REMEMBER_ME": { + "defaultMessage": "Remember me" + }, + "SIGN_IN": { + "defaultMessage": "Sign In" + }, + "SIGN_UP": { + "defaultMessage": "Sign Up" + }, + "SING_IN": { + "defaultMessage": "Sign In" + }, + "TERMS_AND_CONDITIONS": { + "defaultMessage": "Term And Conditions" + }, + "USER_INACTIVE": { + "defaultMessage": "Sorry, your account has not been activated yet. You'll receive a notification email when it becomes active. Stay tuned!." + }, + "WELCOME": { + "defaultMessage": "Welcome" + } +} \ No newline at end of file diff --git a/src/lang/en.json b/lang/es.json similarity index 97% rename from src/lang/en.json rename to lang/es.json index 0177270f..41e98ba8 100644 --- a/src/lang/en.json +++ b/lang/es.json @@ -58,6 +58,6 @@ "defaultMessage": "Sorry, your account has not been activated yet. You'll receive a notification email when it becomes active. Stay tuned!." }, "WELCOME": { - "defaultMessage": "Welcome" + "defaultMessage": "Bienvenido" } } \ No newline at end of file diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 00000000..48fbc476 Binary files /dev/null and b/public/favicon.png differ diff --git a/src/LoginPage.js b/src/LoginPage.js index c106f35f..1e5ca72b 100644 --- a/src/LoginPage.js +++ b/src/LoginPage.js @@ -104,16 +104,18 @@ class LoginPage extends React.Component { const messages = props.messages; const locale = props.locale; + const defaultLocale = 'en' this.state = { locale: locale, - message: messages + messages: messages, + defaultLocale: defaultLocale }; intl = createIntl( { locale: locale, - defaultLocale: 'en' + defaultLocale: defaultLocale }, messages, cache @@ -122,7 +124,7 @@ class LoginPage extends React.Component { render() { return ( - +
diff --git a/src/compiled-lang/en.json b/src/compiled-lang/en.json new file mode 100644 index 00000000..fc192f3f --- /dev/null +++ b/src/compiled-lang/en.json @@ -0,0 +1,122 @@ +{ + "ABOUT_US": [ + { + "type": 0, + "value": "About Us" + } + ], + "CONTACT_US": [ + { + "type": 0, + "value": "Contact Us" + } + ], + "DONATIONS": [ + { + "type": 0, + "value": "PayPal Donations" + } + ], + "DONT_HAVE_ACCOUNT": [ + { + "type": 0, + "value": "Don't have an account ?" + } + ], + "EMAIL": [ + { + "type": 0, + "value": "Email" + } + ], + "FAQ": [ + { + "type": 0, + "value": "F.A.Q." + } + ], + "FEEDBACK": [ + { + "type": 0, + "value": "Feedback" + } + ], + "FORGOT_PASSWORD": [ + { + "type": 0, + "value": "Forgot Password ?" + } + ], + "LOGIN_ERROR": [ + { + "type": 0, + "value": "The email address or password you entered is not valid." + } + ], + "LOG_INTO": [ + { + "type": 0, + "value": "Log Into Your Account" + } + ], + "NO_PRODUCTION_DATABASE_CONFIGURED": [ + { + "type": 0, + "value": "Warning: Although HSQLDB is bundled with WiseMapping by default during the installation, we do not recommend this database for production use. Please consider using MySQL 5.7 instead. You can find more information how to configure MySQL" + } + ], + "OPEN_SOURCE": [ + { + "type": 0, + "value": "Open Source" + } + ], + "PASSWORD": [ + { + "type": 0, + "value": "Password" + } + ], + "REMEMBER_ME": [ + { + "type": 0, + "value": "Remember me" + } + ], + "SIGN_IN": [ + { + "type": 0, + "value": "Sign In" + } + ], + "SIGN_UP": [ + { + "type": 0, + "value": "Sign Up" + } + ], + "SING_IN": [ + { + "type": 0, + "value": "Sign In" + } + ], + "TERMS_AND_CONDITIONS": [ + { + "type": 0, + "value": "Term And Conditions" + } + ], + "USER_INACTIVE": [ + { + "type": 0, + "value": "Sorry, your account has not been activated yet. You'll receive a notification email when it becomes active. Stay tuned!." + } + ], + "WELCOME": [ + { + "type": 0, + "value": "Welcome" + } + ] +} \ No newline at end of file diff --git a/src/compiled-lang/es.json b/src/compiled-lang/es.json new file mode 100644 index 00000000..fc08cff9 --- /dev/null +++ b/src/compiled-lang/es.json @@ -0,0 +1,82 @@ +{ + "ABOUT_US": [{ + "type": 0, + "value": "About Us" + }], + "CONTACT_US": [{ + "type": 0, + "value": "Contact Us" + }], + "DONATIONS": [{ + "type": 0, + "value": "PayPal Donations" + }], + "DONT_HAVE_ACCOUNT": [{ + "type": 0, + "value": "Don't have an account ?" + }], + "EMAIL": [{ + "type": 0, + "value": "Email" + }], + "FAQ": [{ + "type": 0, + "value": "F.A.Q." + }], + "FEEDBACK": [{ + "type": 0, + "value": "Feedback" + }], + "FORGOT_PASSWORD": [{ + "type": 0, + "value": "Forgot Password ?" + }], + "LOGIN_ERROR": [{ + "type": 0, + "value": "The email address or password you entered is not valid." + }], + "LOG_INTO": [{ + "type": 0, + "value": "Log Into Your Account" + }], + "NO_PRODUCTION_DATABASE_CONFIGURED": [{ + "type": 0, + "value": "Warning: Although HSQLDB is bundled with WiseMapping by default during the installation, we do not recommend this database for production use. Please consider using MySQL 5.7 instead. You can find more information how to configure MySQL" + }], + "OPEN_SOURCE": [{ + "type": 0, + "value": "Open Source" + }], + "PASSWORD": [{ + "type": 0, + "value": "Password" + }], + "REMEMBER_ME": [{ + "type": 0, + "value": "Remember me" + }], + "SIGN_IN": [{ + "type": 0, + "value": "Sign In" + }], + "SIGN_UP": [{ + "type": 0, + "value": "Sign Up" + }], + "SING_IN": [{ + "type": 0, + "value": "Sign In" + }], + "TERMS_AND_CONDITIONS": [{ + "type": 0, + "value": "Term And Conditions" + }], + "USER_INACTIVE": [{ + "type": 0, + "value": "Sorry, your account has not been activated yet. You'll receive a notification email when it becomes active. Stay tuned!." + }], + "WELCOME": [{ + "type": 0, + "value": "Bienvenido" + }] +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 0e09b3bb..4d4ef777 100644 --- a/src/index.js +++ b/src/index.js @@ -6,19 +6,26 @@ import LoginPage from './LoginPage.js'; function loadLocaleData(locale) { switch (locale) { - case 'en': - return import('./lang/es.json') + case 'es': + return import('./compiled-lang/es.json') default: - return import('./lang/es.json') + return import('./compiled-lang/en.json') } } -async function bootstrapApplication(locale) { - const messages = loadLocaleData(locale); +async function bootstrapApplication() { + const locale = window.navigator.language; + console.log("Browser Locale:" + window.navigator.language) + + const messages = loadLocaleData(locale); + console.log("loadLocaleData:" + toString(messages)) + + ReactDOM.render( - + , document.getElementById('root') ) } -bootstrapApplication('en') + +bootstrapApplication() diff --git a/src/lang/es.json b/src/lang/es.json deleted file mode 100644 index d8f08d8b..00000000 --- a/src/lang/es.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "FORGOT_PASSWORD": { - "defaultMessage": "Olvido Password" - } -} \ No newline at end of file