Ex_doc: Spanish language support

How can I change the language in ex_doc?
“Summary” (English) -> “Resumen” (Spanish)
“Functions” (English) -> “Funciones” (Spanish)

There is the :language option available to it, perhaps it does already what you want?

:language - Identify the primary language of the documents, its value must be a valid BCP 47language tag; default: “en”

https://hexdocs.pm/ex_doc/Mix.Tasks.Docs.html

2 Likes
  def project do
    [
      app: :hello_alchemy,
      version: "0.1.0",
      elixir: "~> 1.6",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      name: "Hello Alchemy",
      docs: [main: "HelloAlchemy",
             language: "es-ES"]
    ]
  end

language: “es” / language: “es-ES” does nothing.

Currently, the only way to change the language is to fork the project and update the templates yourself, see: https://github.com/elixir-lang/ex_doc/tree/master/lib/ex_doc/formatter/html/templates

If you’d like to work on making this configurable, we could definitely discuss it, open up a new issue or comment on https://github.com/elixir-lang/ex_doc/issues/466.

The :language option is just a hint for the generated epub file.

3 Likes

Yes, of course!. I believe it would be desirable to add support for gettext in ExDoc.
I would separate by locale:

  • Package: ex_doc (main).
  • Package (optional): ex_doc_locale_es_ES (spanish - spain).
  • Package (optional): ex_doc_locale_gl_ES (galician - spain).
  • Package (optional): ex_doc_locale_pt_PT (portuguese - portugal)

Doc sidebar: Add “locale selector”.

locale_selector

Thanks a lot for your assistance!

Hi all,

Finally, I got the problem solved: PR1030

translation.ex
Spanish translations: es.ex

Thank you for all your help

2 Likes