Skip to content

Instantly share code, notes, and snippets.

@amatalai
Created April 24, 2018 10:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amatalai/1877f48a195f578682cfd20e66c6544e to your computer and use it in GitHub Desktop.
Save amatalai/1877f48a195f578682cfd20e66c6544e to your computer and use it in GitHub Desktop.
Workaround for gettext.extract issue with umbrella app
defmodule Mix.Tasks.Gettext.Extract.Umbrella do
use Mix.Task
@recursive false
def run(args) do
unless Mix.Project.umbrella?() do
msg =
"Cannot run task gettext.extract.umbrella from place " <>
"other than umbrella application root dir."
Mix.raise(msg)
end
_ = Application.ensure_all_started(:gettext)
force_recompile_and_extract()
Mix.Task.run("gettext.extract", args)
end
defp force_recompile_and_extract do
Gettext.Extractor.enable()
Mix.Task.run("compile", ["--force"])
after
Gettext.Extractor.disable()
end
end
@jstlroot
Copy link

jstlroot commented Jun 4, 2019

You, sir, are my hero. Thank you so much. <3

@amatalai
Copy link
Author

amatalai commented Jun 5, 2019

😄

@shahryarjb
Copy link

Hi @amatalai I couldn't use your Workaround, I crate a folder on "apps/mix/tasks/gettext.extract.umbrella.ex" after that I call it

mix gettext.extract.umbrella
warning: path "apps/tasks" is a directory but it has no mix.exs. Mix won't consider this directory as part of your umbrella application. Please add a "mix.exs" or set the ":apps" key in your umbrella configuration with all relevant apps names as atoms

for first time it compiles and show me some warning . should I create a project just for Gettext? do you have any example ?

@dkuku
Copy link

dkuku commented Nov 11, 2022

Hi @amatalai I couldn't use your Workaround, I crate a folder on "apps/mix/tasks/gettext.extract.umbrella.ex" after that I call it

mix gettext.extract.umbrella
warning: path "apps/tasks" is a directory but it has no mix.exs. Mix won't consider this directory as part of your umbrella application. Please add a "mix.exs" or set the ":apps" key in your umbrella configuration with all relevant apps names as atoms

for first time it compiles and show me some warning . should I create a project just for Gettext? do you have any example ?

create it in apps/any_of_your_apps/lib/mix/tasks

@znewbiez1001
Copy link

Thank you so much! This saved my career life, bro!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment