-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdate-localizer
43 lines (36 loc) · 2.25 KB
/
date-localizer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{% assign english_days = "Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday" | split: ", " %}
{% assign spanish_days = "Domingo, Lunes, Martes, Miércoles, Jueves, Viernes, Sábado" | split: ", " %}
{% assign french_days = "Dimanche, Lundi, Mardi, Mercredi, Jeudi, Vendredi, Samedi" | split: ", " %}
{% assign portuguese_days = "Domingo, Segunda-feira, Terça-feira, Quarta-feira, Quinta-feira, Sexta-feira, Sábado" | split: ", " %}
{% assign english_months = "January, February, March, April, May, June, July, August, September, October, November, December" | split: ", " %}
{% assign spanish_months = "Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre" | split: ", " %}
{% assign french_months = "Janvier, Février, Mars, Avril, Mai, Juin, Juillet, Août, Septembre, Octobre, Novembre, Décembre" | split: ", " %}
{% assign portuguese_months = "Janeiro, Fevereiro, Março, Abril, Maio, Junho, Julho, Agosto, Setembro, Outubro, Novembro, Dezembro" | split: ", " %}
{% assign string_date = "now" %}
{% assign date_object = string_date | date: "%Y-%m-%d" %}
{% assign month_index = string_date | date: "%m" | minus: 1 %}
{% assign english_day = date_object | date: "%A" %}
{% for day in english_days %}
{% if day == english_day %}
{% assign day_index = forloop.index0 %}
{% comment %} use this variable assignment for testing {% endcomment %}
{% assign language = 'pt' %}
{% case language %}
{% when 'es' %}
{% assign day = spanish_days[day_index] %}
{% assign month = spanish_months[month_index] %}
{% capture date_format %}{{spanish_days[day_index]}} {{string_date | date: "%d"}} de {{month}}{% endcapture %}
{% when 'fr' %}
{% assign day = french_days[day_index] %}
{% assign month = french_months[month_index] %}
{% capture date_format %}{{french_days[day_index]}} {{string_date | date: "%d"}} {{month}}{% endcapture %}
{% when 'pt' %}
{% assign day = portuguese_days[day_index] %}
{% assign month = portuguese_months[month_index] %}
{% capture date_format %}{{portuguese_days[day_index]}} {{string_date | date: "%d"}} de {{month}}{% endcapture %}
{% else %}
{% assign date_format = "now" | date: '%A, %B %d' %}
{% endcase %}
{% endif %}
{% endfor %}
Date format: {{date_format}}