Migrate to the Aparoksha Gitea instance
All checks were successful
Deploy Docs / publish (push) Successful in 18s
SwiftLint / SwiftLint (push) Successful in 6s

This commit is contained in:
david-swift 2024-10-07 14:58:15 +02:00
parent ecb58cdd5d
commit 97d086a7bb
26 changed files with 60 additions and 302 deletions

View File

@ -1,5 +1,4 @@
## Steps
- [ ] Add your name or username and a link to your GitHub profile into the [Contributors.md][1] file.
- [ ] Build the project on your machine. If it does not compile, fix the errors.
- [ ] Describe the purpose and approach of your pull request below.
- [ ] Submit the pull request. Thank you very much for your contribution!
@ -10,5 +9,3 @@ _If there is a related issue, add the link._
## Approach
_Describe how this pull request solves the problem or adds the feature._
[1]: /Contributors.md

34
.gitea/workflows/docs.yml Normal file
View File

@ -0,0 +1,34 @@
name: Deploy Docs
on:
push:
branches: ["main"]
jobs:
publish:
runs-on: david-macbook
steps:
- uses: actions/checkout@v4
- name: Build Docs
run: |
xcrun xcodebuild docbuild \
-scheme Localized \
-destination 'generic/platform=macOS' \
-derivedDataPath "$PWD/.derivedData" \
-skipPackagePluginValidation
xcrun docc process-archive transform-for-static-hosting \
"$PWD/.derivedData/Build/Products/Debug/Localized.doccarchive" \
--output-path "docs" \
--hosting-base-path "/"
- name: Modify Docs
run: |
echo "<script>window.location.href += \"/documentation/localized\"</script><p>Please enable JavaScript to view the documentation <a href='/documentation/localized'>here</a>.</p>" > docs/index.html;
sed -i '' 's/,2px/,10px/g' docs/css/index.*.css
- name: Upload
uses: wangyucode/sftp-upload-action@v2.0.2
with:
host: 'volans.uberspace.de'
username: 'akforum'
password: ${{ secrets.password }}
localDir: 'docs'
remoteDir: '/var/www/virtual/akforum/localized.aparoksha.dev/'

View File

@ -3,17 +3,17 @@ name: SwiftLint
on:
push:
paths:
- '.github/workflows/swiftlint.yml'
- '.gitea/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'
pull_request:
paths:
- '.github/workflows/swiftlint.yml'
- '.gitea/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'
workflow_dispatch:
paths:
- '.github/workflows/swiftlint.yml'
- '.gitea/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'
@ -21,7 +21,7 @@ jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: SwiftLint
uses: norio-nomura/action-swiftlint@3.2.1
with:

View File

@ -94,11 +94,6 @@ disabled_rules:
# Custom Rules
custom_rules:
github_issue:
name: 'GitHub Issue'
regex: '//.(TODO|FIXME):.(?!.*(https://github\.com/AparokshaUI/Localized/issues/\d))'
message: 'The related GitHub issue must be included in a TODO or FIXME.'
severity: warning
fatal_error:
name: 'Fatal Error'

View File

@ -1,35 +0,0 @@
# Contributing
Thank you very much for taking the time for contributing to this project.
## Report a Bug
Just open a new issue on GitHub and describe the bug. It helps if your description is detailed. Thank you very much for your contribution!
## Suggest a New Feature
Just open a new issue on GitHub and describe the idea. Thank you very much for your contribution!
## Pull Requests
I am happy for every pull request, you do not have to follow these guidelines. However, it might help you to understand the project structure and make it easier for me to merge your pull request. Thank you very much for your contribution!
### 1. Fork & Clone this Project
Start by clicking on the `Fork` button at the top of the page. Then, clone this repository to your computer.
### 2. Open the Project
Open the project folder in GNOME Builder, Xcode or another IDE.
### 3. Understand the Project Structure
- The `README.md` file contains a description of the app or package.
- The `Contributors.md` file contains the names or usernames of all the contributors with a link to their GitHub profile.
- The `LICENSE.md` contains a GPL-3.0 license.
- `CONTRIBUTING.md` is this file.
- Directory `Icons` that contains the icons.
- `Sources` contains the source code of the project.
### 4. Edit the Code
Edit the code. If you add a new type, add documentation in the code.
### 5. Commit to the Fork
Commit and push the fork.
### 6. Pull Request
Open GitHub to submit a pull request. Thank you very much for your contribution!

View File

@ -1,3 +0,0 @@
# Contributors
- [david-swift](https://github.com/david-swift)

View File

@ -1,7 +0,0 @@
# Reference Documentation
## Enums
- [Generation](enums/Generation.md)
This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs)

View File

@ -1,10 +0,0 @@
**ENUM**
# `Generation`
A type containing the generation function for the plugin.
## Methods
### `main()`
Generate the Swift code for the plugin.

View File

@ -1,8 +0,0 @@
# Reference Documentation
## Enums
- [Generation](enums/Generation.md)
- [Generation.GenerationError](enums/Generation.GenerationError.md)
This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs)

View File

@ -1,19 +0,0 @@
**ENUM**
# `Generation.GenerationError`
An error that occurs during code generation.
## Cases
### `missingTranslationInDefaultLanguage(key:)`
A translation in the default language missing for a specific key.
Missing translations in other languages will cause the default language to be used.
### `unknownYMLPasingError`
An unknown error occured while parsing the YML.
### `missingDefaultLanguage`
The default language information is missing.

View File

@ -1,91 +0,0 @@
**ENUM**
# `Generation`
Generate the Swift code for the plugin and macro.
## Properties
### `indentOne`
Number of spaces for indentation 1.
### `indentTwo`
Number of spaces for indentation 2.
### `indentThree`
Number of spaces for indentation 3.
## Methods
### `getCode(yml:)`
Get the Swift code for the plugin and macro.
- Parameter yml: The YML code.
- Returns: The code.
### `generateEnumCases(dictionary:)`
Generate the cases for the `Localized` enumeration.
- Parameter dictionary: The parsed YML.
- Returns: The syntax.
### `generateStaticLocVariables(dictionary:)`
Generate the static variables and functions for the `Loc` type.
- Parameter dictionary: The parsed YML.
- Returns: The syntax.
### `generateTranslations(dictionary:defaultLanguage:)`
Generate the variables for the translations.
- Parameters:
- dictionary: The parsed YML.
- defaultLanguage: The default language.
- Returns: The syntax.
### `parseValue(defaultTranslation:translations:language:arguments:)`
Parse the content of a switch case.
- Parameters:
- defaultTranslation: The translation without any conditions (always required).
- translations: All the available translations for an entry.
- language: The language.
- arguments: The arguments of the entry.
- Returns: The syntax.
### `generateLanguageFunction(dictionary:defaultLanguage:)`
Generate the function for getting the translated string for a specified language code.
- Parameters:
- dictionary: The parsed YML.
- defaultLanguage: The default language.
- Returns: The syntax.
### `getLanguages(dictionary:)`
Get the available languages.
- Parameter dictionary: The parsed YML.
- Returns: The syntax
### `parse(key:)`
Parse the key for a phrase.
- Parameter key: The key definition including parameters.
- Returns: The key.
### `parse(translation:arguments:)`
Parse the translation for a phrase.
- Parameters:
- translation: The translation without correct escaping.
- arguments: The arguments.
- Returns: The syntax.
### `indent(_:by:)`
Indent each line of a text by a certain amount of whitespaces.
- Parameters:
- string: The text.
- count: The indentation.
- Returns: The syntax.

View File

@ -1,7 +0,0 @@
# Reference Documentation
## Enums
- [System](enums/System.md)
This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs)

View File

@ -1,16 +0,0 @@
**ENUM**
# `System`
The type system contains a function for parsing the system language.
## Properties
### `systemLanguage`
Remembers the system language after the first request.
## Methods
### `getLanguage()`
Get the system language.
- Returns: The system language.

View File

@ -1,12 +0,0 @@
# Reference Documentation
## Structs
- [LocalizedMacro](structs/LocalizedMacro.md)
- [LocalizedPlugin](structs/LocalizedPlugin.md)
## Enums
- [LocalizedMacro.LocalizedError](enums/LocalizedMacro.LocalizedError.md)
This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs)

View File

@ -1,14 +0,0 @@
**ENUM**
# `LocalizedMacro.LocalizedError`
The errors the expansion can throw.
## Cases
### `invalidStringLiteral`
The string literal syntax is invalid.
### `invalidDefaultLanguage`
The default language syntax is invalid.

View File

@ -1,18 +0,0 @@
**STRUCT**
# `LocalizedMacro`
Implementation of the `localized` macro, which takes YML
as a string and converts it into two enumerations.
Access a specific language using `Localized.key.language`, or use `Localized.key.string`
which automatically uses the system language on Linux, macOS and Windows.
Use `Loc.key` for a quick access to the automatically localized value.
## Methods
### `expansion(of:in:)`
Expand the `localized` macro.
- Parameters:
- node: Information about the macro call.
- context: The expansion context.
- Returns: The enumerations `Localized` and `Loc`.

View File

@ -1,10 +0,0 @@
**STRUCT**
# `LocalizedPlugin`
The compiler plugin offering the `localized` macro.
## Properties
### `providingMacros`
The macros.

View File

@ -1,17 +0,0 @@
# Reference Documentation
## LocalizedMacros
Find documentation for the `localized` macro [here](LocalizedMacros/README.md).
## Localized
Find documentation for the `System` enumeration [here](Localized/README.md).
## Generation
Find documentation for the generation executable used by the plugin [here](Generation/README.md).
## GenerationLibrary
Find documentation for the generation used by the plugin and macro [here](GenerationLibrary/README.md).

View File

@ -1,8 +0,0 @@
docs:
@sourcedocs generate --min-acl private -r --spm-module Localized --output-folder Documentation/Localized
@sourcedocs generate --min-acl private -r --spm-module LocalizedMacros --output-folder Documentation/LocalizedMacros
@sourcedocs generate --min-acl private -r --spm-module Generation --output-folder Documentation/Generation
@sourcedocs generate --min-acl private -r --spm-module GenerationLibrary --output-folder Documentation/GenerationLibrary
swiftlint:
@swiftlint --autocorrect

View File

@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0
//
// Package.swift
// Localized
@ -62,5 +62,6 @@ let package = Package(
"GenerateLocalized"
]
)
]
],
swiftLanguageModes: [.v5]
)

View File

@ -20,17 +20,17 @@ struct Plugin: BuildToolPlugin {
func createBuildCommands(context: PluginContext, target: Target) throws -> [Command] {
guard let target = target.sourceModule,
let inputFile = target.sourceFiles.first(
where: { ["Localized.yml", "Localized.yaml"].contains($0.path.lastComponent) }
where: { ["Localized.yml", "Localized.yaml"].contains($0.url.lastPathComponent) }
) else {
return []
}
let outputFile = context.pluginWorkDirectory.appending(subpath: "Localized.swift")
let outputFile = context.pluginWorkDirectoryURL.appending(path: "Localized.swift")
return [
.buildCommand(
displayName: "Generating Localized.swift",
executable: try context.tool(named: "Generation").path,
arguments: [inputFile.path.string, outputFile.string],
inputFiles: [inputFile.path],
executable: try context.tool(named: "Generation").url,
arguments: [inputFile.url.path, outputFile.path],
inputFiles: [inputFile.url],
outputFiles: [outputFile]
)
]

View File

@ -4,12 +4,12 @@
</p>
<p align="center">
<a href="https://github.com/AparokshaUI/Localized">
GitHub
<a href="https://localized.aparoksha.dev/">
Docs
</a>
·
<a href="Documentation/README.md">
Contributor Docs
<a href="https://git.aparoksha.dev/aparoksha/localized">
Code
</a>
</p>
@ -60,7 +60,7 @@ print(Localized.house.fr)
2. Open the `Package.swift` file.
3. Into the `Package` initializer, under `dependencies`, paste:
```swift
.package(url: "https://github.com/AparokshaUI/Localized", from: "0.1.0")
.package(url: "https://git.aparoksha.dev/aparoksha/localized", from: "0.1.0")
```
## Usage
@ -129,10 +129,9 @@ let export = Localized.export.string(for: "de-CH")
- [Yams](https://github.com/jpsim/Yams) licensed under the [MIT license](https://github.com/jpsim/Yams/blob/main/LICENSE)
### Other Thanks
- The [contributors][7]
- [DocC](https://github.com/apple/swift-docc) used for the documentation
- [SwiftLint][8] for checking whether code style conventions are violated
- The programming language [Swift][9]
- [SourceDocs][10] used for generating the [docs][11]
[1]: Tests/
[2]: #goals

View File

@ -18,7 +18,7 @@ public enum Generation {
let yml = try String(contentsOfFile: CommandLine.arguments[1])
let content = try GenerationLibrary.Generation.getCode(yml: yml)
let outputPathIndex = 2
FileManager.default.createFile(
_ = FileManager.default.createFile(
atPath: CommandLine.arguments[outputPathIndex],
contents: .init(("import Localized" + "\n\n" + content[0] + "\n\n" + content[1]).utf8)
)

View File

@ -0,0 +1,7 @@
# ``Localized``
_Localized_ provides a Swift package plugin for localizing cross-platform Swift code.
## Getting Started
Find instructions on how to use the library in the [README in the Git repository](https://git.aparoksha.dev/aparoksha/localized#readme).