Advent Of Vue is a series of 24 Vue coding challenges that are sent out every day from December 1 to December 24 via a dedicated newsletter. If you'd like to receive more of these puzzles in the future, go ahead and sign up!
Use Vue I18n to create a localized "Happy Holidays" greeting and cycle through some locales. Then, print how many days until Christmas 😊... in 🇯🇵, 🇩🇪, and 🇺🇸!
Translations are provided, though you can add your own!
- Localize "Happy Holidays" using Vue i18n.
- Setup a cycle, radio button, or other way of changing what the current locale is.
- Render the current locale.
- Render a flag emoji or icon for each locale.
- Use the Vue i18n date function to localize the date object for "Christmas".
- Render the number of days until Christmas.
- Localize the number of days until Christmas (
days
). - Localize the entire
christmasIsComing
string with thedate
andtime
values to include joining particles ("{ date } is in { time }" or "{date}はあと{time}" -- notice there are no spaces in Japanese 🤔) - Style the
time
part of thechristmasIsComing
string. (Hint: usei18n-t
and the slot syntax)
You'll be editing App.vue
. You don't really need anything below except for Vue i18n.
- We're using Vue i18n for localization. Vue i18n docs are here
- Locales are provided within the
locales
directory. - Messages are loaded within
main.js
for you. - Each
*.json
file maps to a locale. - If you want to add your own language, you can!
- Check out the Vite config if you'd like to see how that works.
- VueUse is included. I ended up using it in the final solution, but it's not necessary.
-
Using the VSCode plugin i18n Ally is suggested -- it displays your translations inside of your editor!
-
This project is using Icones + UnoCSS for icons.
-
Try out the VSCode Plugin Iconify IntelliSense
-
This allows you to use fancy icons... but you can also just use emojis :P
- No date library is provided. No one likes timezone issues, so a correct way to initialize "Christmas Day" is like so:
new Date('2022/12/25')
. - Fun fact: If you were to switch
/
for-
, it would stop using your local timezone! StackOverflow "Date is off-by-one" issue