[
https://issues.apache.org/jira/browse/CB-7102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14061180#comment-14061180
]
ASF GitHub Bot commented on CB-7102:
------------------------------------
Github user rodms10 commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-globalization/pull/17#discussion_r14901564
--- Diff: src/firefoxos/GlobalizationProxy.js ---
@@ -0,0 +1,214 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var GlobalizationError = require('./GlobalizationError');
+
+
+function addLinkToLocales() {
+ // Adding globalization file to the HEAD section
+ // <link rel="resource" type="application/l10n" href="locales/date.ini"
/>
+ var link = document.createElement("link");
+ link.setAttribute("rel", "resource");
+ link.setAttribute("type", "application/l10n");
+ link.setAttribute("href", "locales/date.ini");
+
+ document.head.appendChild(link);
+}
+
+addLinkToLocales();
+
+
+function getPreferredLanguage(successCB, errorCB) {
+ // WARNING: this isn't perfect - there is a difference between UI
language
+ // and preferred language, however it doesn't happen too often.
+ navigator.mozL10n.ready(function() {
+ successCB({value: navigator.mozL10n.language.code});
+ });
+}
+
+function getLocaleName(successCB, errorCB) {
+ navigator.mozL10n.ready(function() {
+ successCB(navigator.mozL10n.language.code);
+ });
+}
+
+function dateToString(successCB, errorCB, params) {
+ var date = new Date(params[0].date);
+ var options = params[0].options;
+
+ navigator.mozL10n.ready(function() {
+ var f = new navigator.mozL10n.DateTimeFormat();
+ successCB({'value': _getStringFromDate(f, date, options)});
+ });
+
+ function _getStringFromDate(f, date, options) {
+ var format = navigator.mozL10n.get('shortDateTimeFormat');
+ if (options) {
+ if (options.selector == 'date') {
+ return f.localeDateString(date);
+ }
+ if (options.selector == 'time') {
+ return f.localeTimeString(date);
+ }
+ if (options.formatLength != 'short') {
+ var format = navigator.mozL10n.get('dateTimeFormat');
--- End diff --
`format` is already declared up top, you can drop the `var` here.
> globalization
> -------------
>
> Key: CB-7102
> URL: https://issues.apache.org/jira/browse/CB-7102
> Project: Apache Cordova
> Issue Type: Sub-task
> Components: FirefoxOS
> Reporter: Piotr Zalewa
> Assignee: Piotr Zalewa
>
> Add globalization support for Firefox OS
--
This message was sent by Atlassian JIRA
(v6.2#6252)