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

Prep for Release and Translation Documentation #680

Merged
merged 2 commits into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,36 @@ You may also want to take a look at `docs.ts` to modify how the generated files

To update the documentation you can run `npm run compile` if you need to compile the code as well or just run `npm run docs` which just generates the documentation.

## Adding Translations for a Language

Translations exist under `src/lang/locale/`. Each translation is a file that should be the 2 letter language short code for the language,
unless it is a specific dialect or version of the language in which case it should be the 2 letter language short code followed by a dash and the dialect short code or identifier (i.e. `pt-br`).

_Note: any missing keys will be defaulted to its English values which allows for partial translation of a language._

### Adding/Updating Values to an Existing Language

If you would like to add a translation, you can add values manually or via running `npm run translate`. If you choose to use the script,
you will be able to add a translation value for a specific language, list untranslated keys in a specified language,
replace translated value with a new value for a specified key, translate all untranslated keys in a language one at a time

If you choose to do so manually, you will need to copy the structure found in [en.ts](src/lang/locale/en.ts) to the language that you want to add values for.

### Adding a New Language

In order to add language support for a new language, create a new file with the following contents:
``` js
// {NAME_OF_LANGUAGE_IN_LANGUAGE_HERE}

export default {};
```

Next add an import statement like `import {LANGUAGE_SHORT_CODE} from './locale/{LANGUAGE_SHORT_CODE}';`
and an entry in `localeMap` that looks something like `{LANGUAGE_SHORT_CODE}`.
Both of these changes need to be added in [helpers.ts](src/lang/helpers.ts).

Once that is done, all that is left is to add values to the language.

## Running Tests

Tests are run by jest. They can be run by either running `npm run test` or `npm run compile`. The output will let you know how many of the tests passed and if any failed, why they failed.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Note: On some machines the `.obsidian` folder may be hidden. On MacOS you should

## Contributing

Contributions are welcome, especially for new rules. If this is something you would like to do, take a look at the
Contributions are welcome, especially for new rules and new translations. If this is something you would like to do, take a look at the
[contribution guidelines](CONTRIBUTING.md).

## Credits
Expand Down
50 changes: 35 additions & 15 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ Options:
- Default: `true`
- Date Created Key: Which YAML key to use for creation date
- Default: `date created`
- Force Date Created Key Value Retention: Reuses the value in the YAML frontmatter for date created instead of the file metadata which is useful for preventing file metadata changes from causing the value to change to a different value.
- Default: `false`
- Date Modified: Insert the date the file was last modified
- Default: `true`
- Date Modified Key: Which YAML key to use for modification date
Expand Down Expand Up @@ -1372,7 +1374,7 @@ Maecenas malesuada dignissim purus ac volutpat.

Alias: `re-index-footnotes`

Re-indexes footnote keys and footnote, based on the order of occurrence (NOTE: This rule deliberately does *not* preserve the relation between key and footnote, to be able to re-index duplicate keys.)
Re-indexes footnote keys and footnote, based on the order of occurrence (NOTE: This rule does *not* work if there is more than one footnote for a key.)



Expand Down Expand Up @@ -1416,24 +1418,45 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit.[^1] Aenean at aliquet f
[^2]: third footnote, inserted later
[^3]: second footnotes
``````
Example: Re-indexing duplicate footnote keys
Example: Re-indexing footnotes preserves multiple references to the same footnote index

Before:

``````markdown
Lorem ipsum at aliquet felis.[^1] Donec dictum turpis quis pellentesque,[^1] et iaculis tortor condimentum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.[^1] Aenean at aliquet felis. Donec dictum turpis quis ipsum pellentesque, et iaculis tortor condimentum.[^1a] Vestibulum nec blandit felis, vulputate finibus purus.[^2] Praesent quis iaculis diam.[^1]

[^1]: first footnote
[^1]: second footnote
[^1a]: third footnote, inserted later
[^2]: second footnotes
``````

After:

``````markdown
Lorem ipsum at aliquet felis.[^1] Donec dictum turpis quis pellentesque,[^2] et iaculis tortor condimentum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.[^1] Aenean at aliquet felis. Donec dictum turpis quis ipsum pellentesque, et iaculis tortor condimentum.[^2] Vestibulum nec blandit felis, vulputate finibus purus.[^3] Praesent quis iaculis diam.[^1]

[^1]: first footnote
[^2]: second footnote
[^2]: third footnote, inserted later
[^3]: second footnotes
``````
Example: Re-indexing footnotes condense duplicate footnotes into 1 when key and footnote are the same

Before:

``````markdown
bla[^1], bla[^1], bla[^2]
[^1]: bla
[^1]: bla
[^2]: bla
``````

After:

``````markdown
bla[^1], bla[^1], bla[^2]

[^1]: bla
[^2]: bla
``````

## Content
Expand Down Expand Up @@ -1809,7 +1832,7 @@ Before:
``````markdown
1. Item 1
2. Item 2
4. Item 3
3. Item 3

Some text here

Expand Down Expand Up @@ -2854,21 +2877,19 @@ After:

``````markdown
# Make sure that code blocks in blockquotes are accounted for correctly
>

> ```js
> var text = 'this is some text';
> ```
>
> ```js
> var other text = 'this is more text';
> ```
>

**Note that the blanks blockquote lines added do not have whitespace after them**

# Doubly nested code block

> >
> > ```js
> > var other text = 'this is more text';
> > ```
Expand Down Expand Up @@ -3013,12 +3034,11 @@ After:
> $$
> \boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
> $$
>

More content here

> Math block doubly nested in blockquote
> >
>
> > $$
> > \boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
> > $$
Expand Down Expand Up @@ -3159,12 +3179,11 @@ After:
> | foo | bar | blob |
> | baz | qux | trust |
> | quux | quuz | glob |
>

More content here

> Table doubly nested in blockquote
> >
>
> > | Column 1 | Column 2 | Column 3 |
> > |----------|----------|----------|
> > | foo | bar | blob |
Expand Down Expand Up @@ -3235,14 +3254,15 @@ line
# H1
line
``````
Example: Empty line before header and after Yaml is removed with `Empty Line Between Yaml and Header=true`
Example: Empty line before header and after Yaml is removed with `Empty Line Between Yaml and Header=false`

Before:

``````markdown
---
key: value
---

# Header
Paragraph here...
``````
Expand Down
2 changes: 1 addition & 1 deletion docs/templates/readme_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Note: On some machines the `.obsidian` folder may be hidden. On MacOS you should

## Contributing

Contributions are welcome, especially for new rules. If this is something you would like to do, take a look at the
Contributions are welcome, especially for new rules and new translations. If this is something you would like to do, take a look at the
[contribution guidelines](CONTRIBUTING.md).

## Credits
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-linter",
"name": "Linter",
"version": "1.11.0",
"version": "1.12.0",
"minAppVersion": "0.15.6",
"description": "Formats and styles your notes. It can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular markdown contents like list, italics, and bold styles; and more with the use of custom rule options as well.",
"author": "Victor Tao",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-linter",
"version": "1.11.0",
"version": "1.12.0",
"description": "Enforces consistent markdown styling for Obsidian (https://obsidian.md). It can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular markdown contents like list, italics, and bold styles; and more with the use of custom rule options as well.",
"main": "main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"1.12.0": "0.15.6",
"1.11.0": "0.15.6",
"1.10.3": "0.15.6",
"1.10.2": "0.15.6",
Expand Down