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

Add option 'add_location' for location line formatting #438

Merged
merged 1 commit into from Nov 21, 2016

Conversation

rrader
Copy link
Contributor

@rrader rrader commented Aug 9, 2016

Support of add_location option added, can be either 'full', 'file'
or 'never'. 'full' includes both file and line number; 'file' includes
only the file name without line number; 'never' doesn't include the
location comment at all (same as --no-location).

Python babel implementation lacks of this option. We would like to use it to avoid merge conflicts while merging po files.

Option add_location is implemented in the GNU xgettext, quote from the manual:

‘--add-location=type’

Generate ‘#: filename:line’ lines (default).

The optional type can be either ‘full’, ‘file’, or ‘never’. If it is not given or ‘full’, it generates the lines with both file name and line number. If it is ‘file’, the line number part is omitted. If it is ‘never’, it completely suppresses the lines (same as --no-location).

https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html

@codecov-io
Copy link

codecov-io commented Aug 9, 2016

Current coverage is 90.18% (diff: 100%)

Merging #438 into master will increase coverage by 0.02%

@@             master       #438   diff @@
==========================================
  Files            24         24          
  Lines          3954       3963     +9   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           3565       3574     +9   
  Misses          389        389          
  Partials          0          0          

Powered by Codecov. Last update d277c12...2ff0f48

Support of add_location option added, can be either 'full', 'file'
or 'never'. 'full' includes both file and line number; 'file' includes
only the file name without line number; 'never' doesn't include the
location comment at all (same as --no-location).
Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some general little notes, nothing that'd warrant rewriting anything. :)


def initialize_options(self):
self.charset = 'utf-8'
self.keywords = None
self.no_default_keywords = False
self.mapping_file = None
self.no_location = False
self.add_location = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically defaults to 'full' though, doesn't it?

self.no_location = True
elif self.add_location == 'file':
self.include_lineno = False

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth it to del self.add_location here, as the variable has already served its purpose and further modifications to it will not have any effect.

@akx
Copy link
Member

akx commented Nov 21, 2016

Thanks for the patch, @rrader! :) Much appreciated.

@akx akx merged commit 15365e2 into python-babel:master Nov 21, 2016
@oleksandr-kuzmenko
Copy link
Contributor

@akx, hello! When will be the new release with this patch?)

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

Successfully merging this pull request may close these issues.

None yet

5 participants