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 a section about string quoting to CONTRIBUTING #2322

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

zas
Copy link
Collaborator

@zas zas commented Sep 21, 2023

Summary

  • This is a…
    • Bug fix
    • Feature addition
    • Refactoring
    • Minor / simple change (like a typo)
    • Other
  • Describe this change in 1-2 sentences:

Problem

  • JIRA ticket (optional): PICARD-XXX

Solution

Action

@zas zas mentioned this pull request Sep 21, 2023
5 tasks
CONTRIBUTING.md Outdated
In above example, 'key' is an identifier, usually using characters from `[a-z0-9_]` set.
But the printed string is translatable (English phrase).


Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 1; Actual: 2 Warning

Expected: 1; Actual: 2
@@ -56,6 +56,50 @@

`gettext` and `gettext-noop` have been built-in the Picard code as `_` and `N_` respectively to provide support for internationalization/localization. You can use them without imports across all of Picard code. Make sure to mark all displayable strings for translation using `_` or `N_` as applicable. You can read more about python-gettext [here](https://docs.python.org/2/library/gettext.html).

### Strings quoting: single or double quotes?

As a general guideline, we tend to use double quotes for translatable strings and/or English phrases; or anything that may contain one or more single quotes.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 157 Warning

Expected: 80; Actual: 157
### Strings quoting: single or double quotes?

As a general guideline, we tend to use double quotes for translatable strings and/or English phrases; or anything that may contain one or more single quotes.
We use single quotes for identifiers and keys (those are unlikely to contain a single quote; and usually no special character or space).

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 136 Warning

Expected: 80; Actual: 136

```

In above example, 'key' is an identifier, usually using characters from `[a-z0-9_]` set.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 88 Warning

Expected: 80; Actual: 88
print(d['small'])
```

In above example, `l1` contains identifiers (keys of dict `d`) while others are English words/phrases.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 102 Warning

Expected: 80; Actual: 102
Copy link
Member

@phw phw left a comment

Choose a reason for hiding this comment

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

This reads good. LGTM

@zas zas marked this pull request as ready for review September 21, 2023 21:52
@zas zas merged commit 6caab73 into metabrainz:master Sep 21, 2023
69 checks passed
@zas zas deleted the string_quoting branch September 21, 2023 21:52
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.

2 participants