translation.E004) You have provided a value for the LANGUAGE_CODE setting that is not in the LANGUAGES setting - django-settings

I've just reimaged my computer, so setting everything back up for my django project, and on running the server, I get this error. I haven't a clue what it is referring to as my original site came out of the box and as I speak English and this site is an internal work site, there is no reason to do anything language based. Does anyone know what this is or how to get past it so I can carry on working? Looking in the settings file, I have this for the Internationalization section:
LANGUAGE_CODE = 'en-GB'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
DATE_INPUT_FORMATS = [
'%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
'%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006'
'%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006'
]
Is this the out of the box English code? if not, could someone tell me what is should be so I can set it back please, I can't find the outofthebox settings in the documentation.

In Django 3.0 you should use LANGUAGE_CODE exactly as mentioned in LANGUAGES list located in django/conf/global_settings.py
The list is a list of two-tuples in the format (language code, language name) – for example, ('ja', 'Japanese'). This specifies which languages are available for language selection.
So, in your case, it will be LANGUAGE_CODE = 'en-gb'

For French-speaking people, you have to change 'fr-fr' to 'fr'

Related

SOAP4R SOAPDateTime format based on GMT

App uses SOAP4r for consuming API/SOAP
But SOAP::SOAPTimeFormat is returning
2015-11-15T16:59:521468.7999999999999545-04:00
chkout.add('purchasedDt ', SOAP::SOAPDateTime.new(basket.purchase_Date))
Using strftime('%Y-%m-%dT%H:%M:%S') is giving the following
chkout.add('purchasedDt ', SOAP::SOAPDateTime.new(basket.purchase_Date.strftime('%Y-%m-%dT%H:%M:%S')))
2015-11-15T16:59:52Z
What App needs is
2015-11-15 16:59:52 -0400
Please advise ...need the format in
yyyy-mm-ddThh:mm:ss-/+gmt
-Fransis
A simple change in your strftime and you can find out more in the doc for Time#strftime
basket.purchase_Date.now.strftime('%Y-%m-%d %H:%M %z')
=> "2016-04-26 22:48 -0400"
Seems like your applicaton accepts the iso8601 format. You can use Time#xmlschema as a shortcut to generate iso8601 compatible strings:
basket.purchase_Date.xmlschema
#=> "2015-11-15T16:59:52-04:00"
Just change this line in your example:
chkout.add('purchasedDt ', SOAP::SOAPDateTime.new(basket.purchase_Date.xmlschema))

Ruby On Rails : local_time gem : I dont want it to wrap date with <time> tag

I have been using local_time to convert servertime to client local time. However now I am using datatables and to sort date/time columns. I have to use date-moment.js plugin of Datatables which uses moment.js to handle date conversions.
My problem is: the local_time's view helper is wrapping the date with < time > tag like this
<time data-format="%B %e, %Y %l:%M%P"
data-local="time"
datetime="2013-11-27T23:43:22Z"
title="November 27, 2013 6:43pm EDT"
data-localized="true">November 27, 2013 6:43pm</time>
The wrapping thing is creating problem for moment.js to get the actual date-time as it expects. I need it to convert the date-time but not wrap with <time> tag. Is it possible. If yes How?
currently created a helper method to extract the core date from the string returned by the gem's local_date method
in views/
<%= extract_date(local_date(workflow.created_at, CommonConstants::DATE_FORMAT_LONG)) %>
# Parse the string generated by local_time gem
# Expectation :
# "<time data-format=\"%B %e, %Y\" data-local=\"time\" datetime=\"2015-10-28T11:19:54Z\">October 28, 2015</time>"
def extract_date(date_string)
date_string.split('>').pop.split('</')[0] rescue ''
end

Create a datetime using strings in rails

What I would like to do is to go from "2013", "December", "20" and to create 2013-12-20.
Does someone have an idea ? Thanks !
Rails provide nice converters in part of it's framework
2.1.2 :001 > "20 december 2013".to_date
=> Fri, 20 Dec 2013
For your required format you can use this bit for formatting:
strftime("The date is %y-%m-%d")
This can be called on any time object.
You can do this:
Date.new(2013, 12, 20)
You can read more about Date here
This is an extension to #Marc-Alexandre Bérubé 's answer to get your desired format:
"20 december 2013".to_date.strftime("%Y-%m-%d")
# => "2013-12-20"

What is Intl library in Dart for?

I read API documents of intl library, but I realy don't have any idea what Intl class helps us.
At first, I have been thinking that the library is like ResourceBundle class in Java.
But now, I can't say for sure...
When should I use intl library?
or Are there any good samples about the library?
Take a look at the intl example in the source code.
From the example comments:
This defines messages for an English locale directly in the program
and has separate libraries that define German and Thai messages
that say more or less the same thing, and prints the message with
the date and time in it formatted appropriately for the locale.
The German file defines a runAt message, which takes two args: time and day
runAt(time, day) =>
Intl.message('Ausgedruckt am $time am $day.', name: 'runAt', args: [time, day]);
The basic_example.dart defines the default, English version
runAt(time, date) =>
Intl.message('Ran at $time on $day', name: 'runAt', args: [time, day]);
You can then use the correct locale:
var de = new Intl('de_DE');
Intl.withLocale(de.locale, () => runAt('10:00', 'Dienstag')).then(print);
// default (en_GB?) locale
Intl.withLocale(new Intl().locale, () => runAt('10:00', 'Tuesday')).then(print);
(print is the default print() function to output the message).

rails db won't save string as date with m/d/y format?

saving a string to my db as a date and having some strange results
if the date is formatted like,
dd/mm/yy it will save
if date is formatted like,
mm/dd/yy it will fail to save silently
in my console if i go
'20/10/2012'.to_date
=> Sat, 20 Oct 2012
it works
if i go
'10/20/2012'.to_date
=> ArgumentError: invalid date ...
it breaks
i used an initializer to set up my default date format to %m/%d/%Y which you can see is accurately reflected in my DATE_FORMATS hash.
Date::DATE_FORMATS
=> {:short=>"%e %b", :long=>"%B %e, %Y", :db=>"%Y-%m-%d", :number=>"%Y%m%d", :long_ordinal=>#<Proc:0x007f8663f1aae0#/Users/ian/.rvm/gems/ruby-1.9.3-p0#rails-3.2/gems/activesupport-3.2.1/lib/active_support/core_ext/date/conversions.rb:12 (lambda)>, :rfc822=>"%e %b %Y", :default=>"%m/%d/%Y"}
Uncertain what is the cause of the issue here, as things seem to be configured correctly. How to resolve?
thank you!
Try:
DateTime.strptime('20/10/2012', '%d/%m/%Y')
Or just use Date if you don't need an associated time:
Date.strptime('20/10/2012', '%d/%m/%Y')
Use gem american_date
In gem file
gem 'american_date'
Now it will save mm/dd/yyyy date format.

Resources