Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seems we now need to run gettext:pot:create to update the pot file #117

Closed
wants to merge 1 commit into from
Closed

Conversation

mreinsch
Copy link

@mreinsch mreinsch commented Dec 6, 2013

I've pulled in latest gettext from https://github.com/ruby-gettext/gettext to avoid fuzzy matching when updating po files and noticed that my pot file was no longer updated when running rake gettext:find. I couldn't pin this to any specific commit in gettext, but running gettext:pot:create upfront works fine for me.

@grosser
Copy link
Owner

grosser commented Dec 7, 2013

works fine here https://github.com/grosser/gettext_i18n_rails_example

  • modify a file touch locale/testlog_phrases.rb
  • modify app.pot by changing a msgid
  • run rake gettext:find
  • app.pot is restored

is it maybe because no file is modified ?

@mreinsch
Copy link
Author

Well, we're still seeing some very strange behaviour with gettext not updating the language files. I think that is an issue in gettext though, and my workaround in this pull request doesn't solve it.
It seems gettext is using timestamps to evaluate whether it needs to update the pot file and thus the other language files. But with git, timestamps don't necessarily mean much, and so only after touching some files manually, gettext finally updated the language files.

@grosser
Copy link
Owner

grosser commented Feb 12, 2014

I found that timestamp business kind of distracting myself ... it does not
take too long to parse all files and with timestamps you cannot see what
code changes in gettext would do, that is why the example app has a hack to
always generate translations.

Do file timestamps not change when a file is updated through git ?
Can you nail it down to something specific so @kou can investigate ?
Do you think just turning off timestamp awareness would be the best
approach ?

On Tue, Feb 11, 2014 at 6:42 PM, Michael Reinsch
notifications@github.comwrote:

Well, we're still seeing some very strange behaviour with gettext not
updating the language files. I think that is an issue in gettext though,
and my workaround in this pull request doesn't solve it.
It seems gettext is using timestamps to evaluate whether it needs to
update the pot file and thus the other language files. But with git,
timestamps don't necessarily mean much, and so only after touching some
files manually, gettext finally updated the language files.

Reply to this email directly or view it on GitHubhttps://github.com//pull/117#issuecomment-34833421
.

@mreinsch
Copy link
Author

Timestamps do change when files are updated through git - but git does not try to preserve them. So when switching branches, there is a chance that all files are getting replaced and thus end up with a current timestamp.

I think not bothering with the timestamps is the best way. If I run the command to update the pot/po files, I do expect it to actually do that. Anything else is confusing. If there is a reason to run it conditionally, that should be a different action like rake gettext:conditionally_update.

@grosser
Copy link
Owner

grosser commented Feb 12, 2014

Can you make a PR to change that, I'll merge it / don't expect anyone to
complain otherwise, only reason I could imagine would be it taking too long
... but then they can use timestamped ...

On Tue, Feb 11, 2014 at 8:03 PM, Michael Reinsch
notifications@github.comwrote:

Timestamps do change when files are updated through git - but git does not
try to preserve them. So when switching branches, there is a chance that
all files are getting replaced and thus end up with a current timestamp.

I think not bothering with the timestamps is the best way. If I run the
command to update the pot/po files, I do expect it to actually do that.
Anything else is confusing. If there is a reason to run it conditionally,
that should be a different action like rake gettext:conditionally_update.

Reply to this email directly or view it on GitHubhttps://github.com//pull/117#issuecomment-34836919
.

@mreinsch
Copy link
Author

Let me see if I can find the time to do it. It's probably going to take some time as I'm not very familiar with the gettext internals.
I'll close this pull request as we've concluded that this won't fix the actual issue.

@mreinsch mreinsch closed this Feb 12, 2014
@mreinsch mreinsch deleted the gettext3 branch February 12, 2014 05:24
@kou
Copy link
Contributor

kou commented Feb 12, 2014

Is it the request in the pull request that rake gettext:find should always generate .pot file even if it isn't needed to regenerate?

If it is true, I'll add rake gettext:pot:create:force task to gettext gem.

@grosser
Copy link
Owner

grosser commented Feb 12, 2014

I think it has more to do with rake gettext:find not updating when there were changes, I ran into this because I'm trying to test/change task internals, but not sure how to produce the other problem discussed here ...

@kou
Copy link
Contributor

kou commented Feb 18, 2014

OK... It seems that I don't understand the problem discussed here...

If there is a command line list to reproduce the problem discussed here, I may solve this.

@mreinsch
Copy link
Author

How to reproduce:

echo "_('Some new string')" > app/test.rb
touch locale/app.pot
rake gettext:find

This will cause the locale files to not get regenerated. Note that I'm using touch in the example to make it easy to reproduce. In real world the touch is done by git as a result of switching branches for instance.

So please do not rely on timestamps. If I run rake gettext:find, I really want it to actually do that because I know I have changed strings.

@grosser
Copy link
Owner

grosser commented Feb 23, 2014

How about we make the example hack official then ?
https://github.com/grosser/gettext_i18n_rails_example/blob/master/Rakefile#L16-L22and
if we are happy with it and there is an official way we change it.
Can you make a PR for that ?

On Sun, Feb 23, 2014 at 7:00 AM, Michael Reinsch
notifications@github.comwrote:

How to reproduce:

echo "_('Some new string')" > app/test.rb
touch locale/app.pot
rake gettext:find

This will cause the locale files to not get regenerated. Note that I'm
using touch in the example to make it easy to reproduce. In real world
the touch is done by git as a result of switching branches for instance.

So please do not rely on timestamps. If I run rake gettext:find, I really
want it to actually do that because I know I have changed strings.

Reply to this email directly or view it on GitHubhttps://github.com//pull/117#issuecomment-35833375
.

@agarian-alex
Copy link

Agreed. I can no longer get rake gettext:find to update the pot or po files. :(

Additionally, specifying msgmerge or xgettext command line options (--add-location, etc) seems to always fail with invalid option.

:(

Edit: And, yes, git doesn't preserve timestamps. So, for instance, if you want to back out a local change to a file with get checkout, the timestamp is updated to now rendering gettext:find non-op. :/

@grosser
Copy link
Owner

grosser commented Mar 14, 2014

can you make a PR ?

@kou
Copy link
Contributor

kou commented Jul 9, 2014

How to reproduce:

echo "_('Some new string')" > app/test.rb
touch locale/app.pot
rake gettext:find

This will cause the locale files to not get regenerated. Note that I'm using touch in the example to make it easy to reproduce. In real world the touch is done by git as a result of switching branches for instance.

You should not manage .pot file by Git. It is an auto generated file. If you don't manage .pot file by Git, your problem will be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants