Sunday, April 29, 2018

New language adding error('Unknown language code si.')

Hello Guys 

I added new language to django . language called Sinhala. My code is look like this.

On settings page 

LANGUAGE_CODE = 'en'
LANGUAGES = [
    ('si', _('Sinhala')),
    ('en', _('English')),
]
TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

LOCALE_PATHS = (
    os.path.join(os.path.dirname(__file__), "../locale"),
)

On locale folder 

__init__.py

LANG_INFO = {
    'si': {
        'bidi': False,
        'code': 'si',
        'name': 'Sinhala',
        'name_local': 'Sinhala',
    },
}
I ran this command after that 
manage.py makemessages -l si  manage.py compilemessages

When i goes to admin URL with sinhala language its working fine i try get all supported language give this error 
<form action="{% url 'set_language' %}" method="post">{% csrf_token %}      <input name="next" type="hidden" value="{{ redirect_to }}" />      <select name="language">          {% get_current_language as LANGUAGE_CODE %}          {% get_available_languages as LANGUAGES %}          {% get_language_info_list for LANGUAGES as languages %}          {% for language in languages %}              <option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>                  {{ language.name_local }} ({{ language.code }})              </option>          {% endfor %}      </select>      <input type="submit" value="Go" />  </form>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2f328be0-d237-4b02-b266-718891a06001%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment