Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1382 (closed defect: fixed)

Opened 12 years ago

Last modified 11 years ago

[PATCH] Don't forget locales directory in setup.py

Reported by: chrisz Owned by: faide
Priority: normal Milestone: 1.5
Component: TurboGears Version: 1.0.1
Severity: normal Keywords:
Cc:

Description

When you deploy a TurboGears project as an egg, as described  here, the locales directory will get lost.

The patch (against the current trunk) makes sure that the locales directory is installed along with the project package.

Attachments

setup_with_locale.patch Download (4.0 KB) - added by chrisz 12 years ago.
Adds locales directory to setup.py and improve get_package_name in util.py
extended_locales.patch Download (8.6 KB) - added by chrisz 12 years ago.
Extended patch that also solves the problem of finding the locales directory
no_package_problem.patch Download (4.1 KB) - added by chrisz 11 years ago.
addresses comment 06/07/07 13:27:31 by jtate
brokensample.tgz Download (83.2 KB) - added by jtate 11 years ago.
Simple case 0, extract, and run the script.
brokensample2.tgz Download (82.4 KB) - added by jtate 11 years ago.
Broken sample 1, extract, cd separatetests, run testscript.sh
no_package_problem_2.patch Download (4.1 KB) - added by chrisz 11 years ago.
addresses comment 06/07/07 20:46:31 by jtate

Change History

Changed 12 years ago by chrisz

Adds locales directory to setup.py and improve get_package_name in util.py

comment:1 Changed 12 years ago by chrisz

The patch now includes an improvement of the get_package_name() function so that it does not get disturbed by the "locales" top level package.

comment:2 Changed 12 years ago by chrisz

One problem is still open, however: Though the locales directory is now installed together with the egg, it is not found when running the application, unless you start the application from inside the egg directory or set the locales path explicitly with i18n.locale_dir. This is because the tg_gettext module looks for a "locales" directory in the current working directory if no path is explicitly set.

comment:3 Changed 12 years ago by faide

This patch applies to 1.0 but does not apply cleanly to trunk... ;( I'm too tired right now. I'll look into the trunk tomorrow... applied in 1.0 (r3031)

Thanks.

comment:4 Changed 12 years ago by faide

  • Owner changed from anonymous to faide

Changed 12 years ago by chrisz

Extended patch that also solves the problem of finding the locales directory

comment:5 Changed 12 years ago by chrisz

Right, the patch is for the 1.0 branch only and may need some modification for the trunk.

I have now added an extended patch that also solves the problem mentioned in the last comment. The idea is to put the package name into the config in the start script, and then look for the locales directory in the parent dir of of the package path. Not sure whether this is really a good solution, but it works for me.

comment:6 Changed 11 years ago by faide

The second patch seems to have been already applied. Someone did this without commenting the ticket ?

Anyway, thanks Chrisz!

comment:7 Changed 11 years ago by faide

Apply what was still relevant to 1.0 branch.

comment:8 Changed 11 years ago by faide

OK, 1.0 now contains both patches (at r3063); but trunk is still too much of a mess ATM.

comment:9 Changed 11 years ago by jtate

This needs to handle projects without "locale" in their setup.py before it can be shipped in the 1.0.x branch. Please address this, or I will revert the patches.

comment:10 Changed 11 years ago by jtate

I'll clarify: When running my test suite against the 1.0 branch, get_package_name() returns None. This causes tg_gettext to fail when attempting to find substitutions for _() stuff.

Changed 11 years ago by chrisz

addresses comment 06/07/07 13:27:31 by jtate

comment:11 Changed 11 years ago by chrisz

Does the newly attached patch solve this issue?

comment:12 Changed 11 years ago by jtate

It's closer. I apologize for not giving you a good test case earlier. Please see the attached.

Changed 11 years ago by jtate

Simple case 0, extract, and run the script.

Changed 11 years ago by jtate

Broken sample 1, extract, cd separatetests, run testscript.sh

Changed 11 years ago by chrisz

addresses comment 06/07/07 20:46:31 by jtate

comment:13 Changed 11 years ago by chrisz

Thanks. I have attached an improved no_package_problem_2.patch

comment:14 Changed 11 years ago by jtate

no_package_problem_2 applied to 1.0 branch. faide can you take it from here to make sure it gets into trunk?

comment:15 Changed 11 years ago by faide

  • Milestone changed from 1.0.3 to 1.1

comment:16 Changed 11 years ago by rejoc

Another issue :

locales are used only when starting the application with the main directory (the one with start-xxx.py) as the default directory. No translations if starting from elsewhere.

comment:17 Changed 11 years ago by chrisz

  • Status changed from new to closed
  • Resolution set to fixed

The patch has been included in TG 1.0 and 1.1 since r3063. In the trunk (TG 2.0) i18n needs to be reimplemented anyway. So I'm closing this now.

We can open a new ticket for the issue mentioned in the last comment.

Note: See TracTickets for help on using tickets.