Could not load translations: Invalid trailing UTF-8 octet in YAML

Im new to rails and trying to internationalize my app with I18n. In the locales yaml file for the spanish version im trying to set up the translations as follows:

es: categories: "Categorias" home: Inicio live_casino: "Casino en Vivo" sportsbook: Deportes

This works like a charm, but as soon as I add the accent in the spanish word like this:

categories: "Categorías"

Rails gives me the following error:

I18n::InvalidLocaleData in WelcomeController#index
can not load translations from .../config/locales/es.yml: #<Psych::SyntaxError: (.../config/locales/es.yml): invalid trailing UTF-8 octet at line 1 column 1>

Ive tried everything ive found in the web and nothing has worked please help!

3 Answers

I opened the locale file in Notepad++ and noticed it was encoded in "UTF-8 w/o BOM".

Click on Encoding -> Convert to UTF-8 and the error went away.

3

Try to put the following line at the beginning of the es.yml file:

# encoding: utf-8 
0

Had the same error, in my case, I had : in the middle of the text, but : is functional sign so get rid of it, this can be caused by any signs that has been copied from online or ord and pasted.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like