Skip to content

Commit e02ac82

Browse files
authored
Merge pull request #265 from cesarParra/translations
Translations
2 parents 49b5ada + 02d49e8 commit e02ac82

File tree

103 files changed

+5125
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+5125
-139
lines changed

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ ApexDocs is a non-opinionated documentation generator for Salesforce Apex classe
1212
It can output documentation in Markdown format, which allows you to use the Static Site Generator of your choice to
1313
create a documentation site that fits your needs, hosted in any static web hosting service.
1414

15+
## Table of Contents
16+
17+
- [👀 Examples](#-examples)
18+
- [🚀 Features](#-features)
19+
- [💿 Installation](#-installation)
20+
- [⚡ Quick Start](#-quick-start)
21+
- [CLI](#cli)
22+
- [Markdown](#markdown)
23+
- [OpenApi](#openapi)
24+
- [Changelog](#changelog)
25+
- [▶️ Available Commands](#️-available-commands)
26+
- [Markdown](#markdown-1)
27+
- [OpenApi](#openapi-1)
28+
- [Changelog](#changelog-1)
29+
- [🔬 Defining a configuration file](#-defining-a-configuration-file)
30+
- [🌐 Translation](#-translation)
31+
- [⤵︎ Importing to your project](#︎-importing-to-your-project)
32+
- [📖 Documentation Guide](#-documentation-guide)
33+
- [📄 Generating OpenApi REST Definitions](#-generating-openapi-rest-definitions)
34+
1535
## 👀 Examples
1636

1737
ApexDocs generates Markdown files, which can be integrated into any Static Site Generation (SSG) engine,
@@ -64,6 +84,7 @@ Here are some live projects using ApexDocs:
6484
* Support for ignoring files and members from being documented
6585
* Namespace support
6686
* Configuration file support
87+
* Translation support for different languages and custom terminology
6788
* Single line ApexDoc Blocks
6889
* Custom tag support
6990
* And much, much more!
@@ -274,6 +295,12 @@ export default defineMarkdownConfig({
274295
sourceDir: 'force-app',
275296
targetDir: 'docs',
276297
scope: ['global', 'public'],
298+
translations: {
299+
sections: {
300+
methods: 'Methods',
301+
properties: 'Properties',
302+
},
303+
},
277304
...
278305
});
279306
```
@@ -595,6 +622,74 @@ export default {
595622
};
596623
```
597624

625+
## 🌐 Translation
626+
627+
ApexDocs supports translations to customize the language and terminology used in the generated documentation.
628+
This feature allows you to:
629+
630+
- **Translate documentation to different languages** (Spanish, French, etc.)
631+
- **Use custom business terminology** (e.g., "Business Operations" instead of "Methods")
632+
- **Partially override specific terms** while keeping the rest in English
633+
634+
### How It Works
635+
636+
The translation system uses:
637+
638+
- **Default English translations** built into the system
639+
- **User-provided overrides** that can be partial or complete
640+
641+
### Configuration
642+
643+
Add a `translations` property to your ApexDocs configuration (JS or TS file) and pass
644+
the appropriate translation object, depending on the generator you're using:
645+
646+
```javascript
647+
import { defineMarkdownConfig } from '@cparra/apexdocs';
648+
649+
export default defineMarkdownConfig({
650+
sourceDir: 'src',
651+
targetDir: 'docs',
652+
scope: ['public', 'global'],
653+
translations: {
654+
sections: {
655+
methods: 'Métodos',
656+
properties: 'Propiedades',
657+
fields: 'Campos',
658+
},
659+
},
660+
});
661+
```
662+
663+
### TypeScript Support
664+
665+
For TypeScript projects, import the translation types for better autocomplete and type safety:
666+
667+
```typescript
668+
import { defineMarkdownConfig } from '@cparra/apexdocs';
669+
import type { UserTranslations } from '@cparra/apexdocs';
670+
671+
const markdownTranslations: UserTranslations['markdown'] = {
672+
sections: {
673+
methods: 'Functions',
674+
},
675+
// ...other translation keys as needed
676+
};
677+
678+
export default defineMarkdownConfig({
679+
sourceDir: 'src',
680+
targetDir: 'docs',
681+
scope: ['public', 'global'],
682+
translations: markdownTranslations,
683+
});
684+
```
685+
686+
### Notes
687+
688+
- Only the **markdown** and **changelog** generators support translations
689+
- All translations are optional - anything not specified uses the English default
690+
691+
For a complete example, see the [translation example](examples/translation/) in this repository.
692+
598693
## ⤵︎ Importing to your project
599694

600695
### Reflection

examples/translation/.forceignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
2+
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
3+
#
4+
5+
package.xml
6+
7+
# LWC configuration files
8+
**/jsconfig.json
9+
**/.eslintrc.json
10+
11+
# LWC Jest
12+
**/__tests__/**

examples/translation/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Sample Project With Provided Translations
2+
3+
Demonstrates how to provide translations to ApexDocs to customize the language and terminology used in generated documentation.
4+
5+
## Overview
6+
7+
The translation feature allows you to:
8+
9+
1. **Translate documentation to different languages** (Spanish, French, etc.)
10+
2. **Use custom business terminology** (e.g., "Business Operations" instead of "Methods")
11+
3. **Partially override specific terms** while keeping the rest in English
12+
13+
## Configuration
14+
15+
Add a `translations` property to your ApexDocs configuration:
16+
17+
```javascript
18+
import { defineMarkdownConfig } from '@cparra/apexdocs';
19+
20+
export default defineMarkdownConfig({
21+
sourceDir: 'src',
22+
targetDir: 'docs',
23+
scope: ['public', 'global'],
24+
translations: {
25+
// Your custom translations here
26+
sections: {
27+
methods: 'Métodos',
28+
properties: 'Propiedades',
29+
fields: 'Campos',
30+
},
31+
},
32+
});
33+
```
34+
35+
## TypeScript Support
36+
37+
If you're using TypeScript, you can import the translation types for better autocomplete and type safety:
38+
39+
```typescript
40+
import { defineMarkdownConfig } from '@cparra/apexdocs';
41+
import type { UserTranslations } from '@cparra/apexdocs';
42+
43+
const translations: UserTranslations = {
44+
markdown: {
45+
sections: {
46+
methods: 'Functions',
47+
},
48+
},
49+
};
50+
51+
export default defineMarkdownConfig({
52+
sourceDir: 'src',
53+
targetDir: 'docs',
54+
scope: ['public', 'global'],
55+
translations: translations.markdown,
56+
});
57+
```
58+
59+
## Notes
60+
61+
- Only the **markdown** and **changelog** generators support translations
62+
- All translations are optional - anything not specified uses the English default
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { defineChangelogConfig, defineMarkdownConfig, UserTranslations } from '../../src';
2+
3+
// Spanish translations
4+
const spanishTranslations: UserTranslations['markdown'] = {
5+
sections: {
6+
methods: 'Métodos',
7+
properties: 'Propiedades',
8+
fields: 'Campos',
9+
constructors: 'Constructores',
10+
namespace: 'Espacio de Nombres',
11+
values: 'Valores',
12+
},
13+
details: {
14+
apiName: 'Nombre API',
15+
type: 'Tipo',
16+
signature: 'Firma',
17+
parameters: 'Parámetros',
18+
returnType: 'Tipo de Retorno',
19+
throws: 'Lanza',
20+
required: 'Requerido',
21+
author: 'Autor',
22+
},
23+
typeSuffixes: {
24+
class: 'Clase',
25+
interface: 'Interfaz',
26+
enum: 'Enum',
27+
trigger: 'Disparador',
28+
},
29+
inheritance: {
30+
inheritance: 'Herencia',
31+
implements: 'Implementa',
32+
},
33+
};
34+
35+
export default {
36+
markdown: defineMarkdownConfig({
37+
sourceDir: 'force-app',
38+
scope: ['global', 'public'],
39+
translations: spanishTranslations,
40+
}),
41+
changelog: defineChangelogConfig({
42+
previousVersionDir: 'previous',
43+
currentVersionDir: 'force-app',
44+
scope: ['global', 'public'],
45+
translations: {
46+
title: 'Registro de Cambios',
47+
},
48+
}),
49+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"orgName": "cesarparra company",
3+
"edition": "Developer",
4+
"features": []
5+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Registro de Cambios
2+
3+
## New Classes
4+
5+
These classes are new.
6+
7+
### BaseClass
8+
9+
### MultiInheritanceClass
10+
11+
### Url
12+
13+
Represents a uniform resource locator (URL) and provides access to parts of the URL.
14+
Enables access to the base URL used to access your Salesforce org.
15+
### SampleClass
16+
17+
aliquip ex sunt officia ullamco anim deserunt magna aliquip nisi eiusmod in sit officia veniam ex
18+
**deserunt** ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
19+
### SampleException
20+
21+
This is a sample exception.
22+
23+
## New Interfaces
24+
25+
These interfaces are new.
26+
27+
### ParentInterface
28+
29+
### SampleInterface
30+
31+
This is a sample interface
32+
33+
## New Enums
34+
35+
These enums are new.
36+
37+
### ReferencedEnum
38+
39+
### SampleEnum
40+
41+
This is a sample enum. This references ReferencedEnum .
42+
43+
This description has several lines
44+
45+
## New Custom Objects
46+
47+
These custom objects are new.
48+
49+
### Account
50+
51+
### Contact
52+
53+
### Event__c
54+
55+
Represents an event that people can register for.
56+
### Price_Component__c
57+
58+
### Product_Price_Component__c
59+
60+
### Product__c
61+
62+
Product that is sold or available for sale.
63+
### Sales_Order_Line__c
64+
65+
Represents a line item on a sales order.
66+
### Sales_Order__c
67+
68+
Custom object for tracking sales orders.
69+
### Speaker__c
70+
71+
Represents a speaker at an event.
72+
73+
## Removed Custom Objects
74+
75+
These custom objects have been removed.
76+
77+
- VisibleCMT__mdt
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Account
2+
3+
## Nombre API
4+
`Account`
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Contact
2+
3+
## Nombre API
4+
`Contact`
5+
6+
## Campos
7+
### PhotoUrl
8+
9+
**Nombre API**
10+
11+
`PhotoUrl__c`
12+
13+
**Tipo**
14+
15+
*Url*

0 commit comments

Comments
 (0)