Skip to content

Commit

Permalink
Merge pull request #176 from nimblehq/chore/refactor-gettext
Browse files Browse the repository at this point in the history
Update Gettext addon
  • Loading branch information
andyduong1920 authored Mar 4, 2022
2 parents c6b8838 + ee98cb8 commit 18ed81b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 50 deletions.
26 changes: 0 additions & 26 deletions lib/nimble_template/addons/variants/phoenix/gettext.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,6 @@ defmodule NimbleTemplate.Addons.Phoenix.Gettext do
""",
"""
"gettext.extract-and-merge": ["gettext.extract --merge --no-fuzzy"],
"gettext.check": [
"gettext.extract-and-merge",
~S/cmd git diff --no-ext-diff --quiet priv\\/gettext || echo "The localization files POs, POTs are NOT up-to-date."/
],
"""
)

Generator.replace_content(
"mix.exs",
"""
"codebase.fix": [
""",
"""
"codebase.fix": [
"gettext.extract-and-merge",
"""
)

Generator.replace_content(
"mix.exs",
"""
codebase: [
""",
"""
codebase: [
"gettext.check",
"""
)

Expand Down
9 changes: 9 additions & 0 deletions priv/templates/nimble_template/.github/workflows/test.yml.eex
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ jobs:
- name: Migrate database
run: mix ecto.migrate

- name: Ensure that localization files (POs, POTs) are up-to-date.
run:
mix gettext.extract-and-merge;

if [ -n "$(git diff --exit-code priv/gettext/)" ]; then
echo "The localization files (POs, POTs) are NOT up-to-date, run \"mix gettext.extract-and-merge\" on your local and push again.";
exit 1;
fi

- name: Run codebase check
run: mix codebase

Expand Down
25 changes: 1 addition & 24 deletions test/nimble_template/addons/variants/gettext_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule NimbleTemplate.Addons.Phoenix.GettextTest do
describe "#apply/2" do
@describetag required_addons: [:TestEnv]

test "injects gettext.extract-and-merge command to mix aliases and codebase.fix", %{
test "injects gettext.extract-and-merge command to mix aliases", %{
project: project,
test_project_path: test_project_path
} do
Expand All @@ -16,29 +16,6 @@ defmodule NimbleTemplate.Addons.Phoenix.GettextTest do
"gettext.extract-and-merge": ["gettext.extract --merge --no-fuzzy"],
"""
end)

assert_file("mix.exs", fn file ->
assert file =~ """
"gettext.check": [
"gettext.extract-and-merge",
~S/cmd git diff --no-ext-diff --quiet priv\\/gettext || echo "The localization files POs, POTs are NOT up-to-date."/
],
"""
end)

assert_file("mix.exs", fn file ->
assert file =~ """
"codebase.fix": [
"gettext.extract-and-merge",
"""
end)

assert_file("mix.exs", fn file ->
assert file =~ """
codebase: [
"gettext.check",
"""
end)
end)
end
end
Expand Down

0 comments on commit 18ed81b

Please sign in to comment.