Coder Social home page Coder Social logo

Comments (5)

arjan avatar arjan commented on June 8, 2024

Same issue here, now using a script like the following:

#! /usr/bin/env elixir
#
# fix-gettext <dir>
#
# Will dedup each file in the given dir, recursively.

System.argv()
|> Stream.flat_map(fn path ->
  if File.dir?(path) do
    Path.wildcard(Path.join(path, "**"))
  else
    path
  end
end)
|> Stream.reject(&File.dir?/1)
|> Stream.map(fn path ->
  data =
    path
    |> File.stream!()
    |> Enum.dedup()

  File.write!(path, data)

  IO.puts("Wrote to: #{path}")
end)
|> Stream.run()

from gettext.

maennchen avatar maennchen commented on June 8, 2024

I believe this is caused by the same as #178

from gettext.

maennchen avatar maennchen commented on June 8, 2024

@josevalim / @whatyouhide Would you potentially be open to a new extract methodology that should resolve the umbrella issue?

  • Add config value extraction_environments, which defaults to [:dev]
  • Add config value extraction_apps, which defaults to the current application
  • The gettext macros will register a module attribute containing all translations and register an @before_compile, which exposes the translations with an __translations__/0 function if the current env is contained in extraction_environments.
  • The Gettext.Extractor will read all modules translations from __translations__/0

Benefits of this approach:

  • mix gettext.extract does not have to recompile since all translations are already available from the normal compilation
  • This approach should easily work for umbrella applications or potentially even dependencies with a few tweaks

If you're open to this approach, I do have some time to try it and see how it performs.

from gettext.

whatyouhide avatar whatyouhide commented on June 8, 2024

@maennchen that's a bigger change than I'd like. Iā€™m ok to do it if it's the only way, but I wanna try to figure out if there is a simpler way instead. Have you tried playing a bit with the recompilation that is triggered by mix gettext.merge? Because if we recompile from scratch correctly we shouldn't be seeing these issues. šŸ˜•

from gettext.

maennchen avatar maennchen commented on June 8, 2024

@whatyouhide I played around with it for a while in this project: https://github.com/jshmrtn/hygeia/tree/main

But even with a complete recompilation, I would run into multiple outcomes at random:

  • New Translations not added
  • Old Translations not removed
  • Or all good

I used this mix tak, which made it better, but didn't resolve it completely.

https://github.com/jshmrtn/hygeia/blob/e3ac39437c19041609162d70baf4ff6e96f846ea/apps/hygeia_gettext/lib/mix/tasks/gettext/extract/umbrella.ex

I haven't really been able to pinpoint the source of the issue.

Everything was resolved when I merged all apps.

from gettext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.