Skip to content

Commit 3d7dcbd

Browse files
committed
Minor fixes
- Remove Logger.debug(...) - add removing trailing "." to safe_folder_name (for Windows)
1 parent d267726 commit 3d7dcbd

File tree

4 files changed

+8
-27
lines changed

4 files changed

+8
-27
lines changed

lib/kanta/backend.ex

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,9 @@ defmodule Kanta.Backend do
3838

3939
# When `mix gettext extract` create POT/PO files based on this backend usage (ex. getext(...) call) across the application codebase.
4040
if Gettext.Extractor.extracting?() do
41-
Logger.debug("#{__MODULE__} OFF")
4241
use Gettext.Backend, opts
4342

44-
Kanta.Utils.GettextRecompiler.setup_recompile_flag(
45-
@flag_file,
46-
"Setting gettext recompile flag for #{__MODULE__}"
47-
)
43+
Kanta.Utils.GettextRecompiler.setup_recompile_flag(@flag_file)
4844
else
4945
Logger.debug("#{__MODULE__} ON")
5046
opts = Keyword.merge(opts, priv: "priv/#{ModuleFolder.safe_folder_name(__MODULE__)}")
@@ -69,13 +65,9 @@ defmodule Kanta.Backend do
6965
bindings
7066
) do
7167
{:ok, translation} ->
72-
Logger.debug("Kanta for \"#{msgid}\"")
73-
7468
{:ok, translation}
7569

7670
{:error, :not_found} ->
77-
Logger.debug("Gettext for \"#{msgid}\"")
78-
7971
backend = fallback_backend()
8072
backend.lgettext(locale, domain, msgctxt, msgid, bindings)
8173
end
@@ -100,11 +92,9 @@ defmodule Kanta.Backend do
10092
bindings
10193
) do
10294
{:ok, translation} ->
103-
Logger.debug("Kanta for \"#{msgid}\"")
10495
{:ok, translation}
10596

10697
{:error, :not_found} ->
107-
Logger.debug("Gettext for \"#{msgid}\"")
10898
backend = fallback_backend()
10999

110100
backend.lngettext(

lib/kanta/backend/fallback_backend.ex

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@ defmodule Kanta.Backend.GettextFallback do
1616

1717
# When `mix gettext extract` create empty stub so that the Kanta.Backend can compile.
1818
if Gettext.Extractor.extracting?() do
19-
Logger.debug("#{__MODULE__} OFF")
20-
2119
def lgettext(_locale, _domain, _msgctxt, _msgid, _bindings), do: nil
2220
def lngettext(_locale, _domain, _msgctxt, _msgid, _msgid_plural, _n, _bindings), do: nil
2321

24-
Kanta.Utils.GettextRecompiler.setup_recompile_flag(
25-
@flag_file,
26-
"Setting fallback recompile flag #{__MODULE__}"
27-
)
22+
Kanta.Utils.GettextRecompiler.setup_recompile_flag(@flag_file)
2823
else
2924
# ...otherwise generate the Gettext.Backend interface
30-
Logger.debug("#{__MODULE__} ON")
3125
use Gettext.Backend, opts
3226
end
3327

lib/kanta/utils/gettext_recompiler.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
defmodule Kanta.Utils.GettextRecompiler do
22
require Logger
33

4-
def setup_recompile_flag(flag_file, message) do
4+
def setup_recompile_flag(flag_file) do
55
if Gettext.Extractor.extracting?() do
6-
Logger.debug(message)
76
File.mkdir_p!(Path.dirname(flag_file))
87
File.touch!(flag_file)
98
end

lib/kanta/utils/module_folder.ex

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ defmodule Kanta.Utils.ModuleFolder do
1616
iex> ModuleFolder.safe_folder_name("Elixir.MyApp.Module", replace_with: "-")
1717
"MyApp-Module"
1818
"""
19-
def safe_folder_name(module, opts \\ []) when is_atom(module) or is_binary(module) do
20-
lowercase? = Keyword.get(opts, :lowercase, true)
21-
replacement = Keyword.get(opts, :replace_with, "_")
19+
def safe_folder_name(module) when is_atom(module) or is_binary(module) do
20+
replacement = "_"
2221

2322
module
2423
|> module_to_string()
2524
|> remove_elixir_prefix()
2625
|> replace_invalid_chars(replacement)
27-
|> maybe_downcase(lowercase?)
26+
|> String.downcase()
2827
end
2928

3029
defp module_to_string(module) when is_atom(module), do: Atom.to_string(module)
@@ -39,8 +38,7 @@ defmodule Kanta.Utils.ModuleFolder do
3938
|> String.replace(~r/[^\w\-\.]/, replacement)
4039
# Collapse multiple replacements
4140
|> String.replace(~r/#{replacement}+/, replacement)
41+
# Comply with Windows naming rules
42+
|> String.trim_trailing(".")
4243
end
43-
44-
defp maybe_downcase(name, true), do: String.downcase(name)
45-
defp maybe_downcase(name, false), do: name
4644
end

0 commit comments

Comments
 (0)