Skip to content

Commit

Permalink
Merge pull request #12 from RealAshampoo/develop
Browse files Browse the repository at this point in the history
Created a readme for the formats package
  • Loading branch information
tjorvenK authored Aug 30, 2022
2 parents ffc1cd3 + 4fd25de commit cf4649f
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,28 @@
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerIgnoreHeight>true</MinVerIgnoreHeight>
<MinVerDefaultPreReleasePhase>prerelease</MinVerDefaultPreReleasePhase>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.Abstractions\src\Ashampoo.Translation.Systems.Formats.Abstractions.csproj"/>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.AshLang\src\Ashampoo.Translation.Systems.Formats.AshLang.csproj"/>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.Gengo\src\Ashampoo.Translation.Systems.Formats.Gengo.csproj"/>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.Json\src\Ashampoo.Translation.Systems.Formats.Json.csproj"/>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.NLang\src\Ashampoo.Translation.Systems.Formats.NLang.csproj"/>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.PO\src\Ashampoo.Translation.Systems.Formats.PO.csproj"/>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.ResX\src\Ashampoo.Translation.Systems.Formats.ResX.csproj"/>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.TsProj\src\Ashampoo.Translation.Systems.Formats.TsProj.csproj"/>
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.Abstractions\src\Ashampoo.Translation.Systems.Formats.Abstractions.csproj" />
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.AshLang\src\Ashampoo.Translation.Systems.Formats.AshLang.csproj" />
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.Gengo\src\Ashampoo.Translation.Systems.Formats.Gengo.csproj" />
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.Json\src\Ashampoo.Translation.Systems.Formats.Json.csproj" />
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.NLang\src\Ashampoo.Translation.Systems.Formats.NLang.csproj" />
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.PO\src\Ashampoo.Translation.Systems.Formats.PO.csproj" />
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.ResX\src\Ashampoo.Translation.Systems.Formats.ResX.csproj" />
<ProjectReference Include="..\..\Ashampoo.Translation.Systems.Formats.TsProj\src\Ashampoo.Translation.Systems.Formats.TsProj.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="../../../LICENSE" Pack="true" PackagePath=""/>
<None Include="../../../ash-logo-icon-big-128x.png" Pack="true" PackagePath=""/>
<None Include="../../../LICENSE" Pack="true" PackagePath="" />
<None Include="../../../ash-logo-icon-big-128x.png" Pack="true" PackagePath="" />
<None Include="README.md" Pack="true" PackagePath=""/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="MinVer" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Ashampoo.Translation.Systems.Formats.Abstractions;
using Microsoft.Extensions.DependencyInjection;

namespace Ashampoo.Translation.Systems.Formats;

/// <summary>
/// This class provides extension methods for the <see cref="IServiceCollection"/> interface.
/// </summary>
public static class DependencyInjection
{
/// <summary>
/// Registers all necessary services and the format implementations.
/// </summary>
/// <param name="services">
/// The <see cref="IServiceCollection"/> to register the services with.
/// </param>
/// <returns>
/// The <see cref="IServiceCollection"/> for chaining.
/// </returns>
/// <exception cref="ArgumentNullException">
/// Thrown if something went wrong during the registration.
/// </exception>
public static IServiceCollection RegisterFormats(this IServiceCollection services)
{
services.AddFormatFactory(configuration =>
{
var path = Path.GetDirectoryName(typeof(DependencyInjection).Assembly.Location);

if (string.IsNullOrWhiteSpace(path))
throw new ArgumentNullException(nameof(path), "Assembly location could not be found.");

configuration.PluginPaths.Add(path);
});
return services;
}
}
158 changes: 158 additions & 0 deletions src/Ashampoo.Translation.Systems.Formats/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Ashampoo-Translation-Systems-Formats

This package provides the implementation of several translation file formats,
such as PO and Json, for the Ashampoo Translation Studio.

## Supported Formats

### AshLang
AshLang is a file format for storing a translations with their english original text.\
An AshLang file is a binary file with the following structure:

TODO: complete readme

### Gengo
The Gengo format is a simple format for storing translations.\
It is meant to be used for sending it to Gengo for translating.\
Gengo is based on Excel (.xlsx) and has a specific structure:\

| [[[ ID ]]] | source | target |
|:-----------------:|:--------------:|:---------------:|
| [[[ first id ]]] | first source | first target |
| [[[ second id ]]] | second source | second target |
| [[[ third id ]]] | third source | third target |

As you can see, the ids are always in the first column and the source and target are in the second and third columns.
Also, the ids are inside of 3 square brackets.\
This is because Gengo doesn't translates strings that are in three square brackets.

### Json
The Json format is a simple format for storing translations.\
It is a JSON file with the following structure:

```json
{
"first id": "first target",
"second id": "second target",
"third id": "third target"
}
```
Json also supports nested objects:

```json
{
"first id": "first target",
"second id": "second target",
"third id": {
"first nested id": "first nested target",
"second nested id": "second nested target",
"third nested id": "third nested target"
}
}
```
The id for translations in nested objects is constructed by concatenating the ids of the parent objects with a `/` .\
For example, the id for the first nested id is `third id/first nested id`.

Additionally, arrays are supported:

```json
{
"first id": [
"first target",
"second target",
"third target"
]
}
```
The id for translations in arrays is constructed by concatenating the id of the parent object with a `/` and the index of the array.\
For example, the id for the first target is `first id/0`.

### NLang
NLang is a simple key-value format.
```
firstId=firstTarget
secondId=secondTarget
thirdId=thirdTarget
```

### PO
The [PO](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html) format is a simple format for storing translations.\
It is a text file with the following structure:

```po
msgid "first source"
msgstr "first target"
msgid "second source"
msgstr "second target"
msgid "third source"
msgstr "third target"
```

Po files can also contain comments, and context.\
Both can be used to store additional information about the translation.\
At the moment, context and comments in files are accepted as inputs, but are not properly handled.\
If a translation has a context, the id of the translation is constructed by concatenating the context with a `/` and the id.\
For the full documentation of the PO format, see the [GNU gettext manual](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html).

### Resx
The Resx format is a simple format for storing translations.\
It is a XML file with the following structure:

```
<?xml version="1.0" encoding="utf-8"?>
<root>
<data name="first id">
<value>first target</value>
</data>
<data name="second id">
<value>second target</value>
</data>
<data name="third id">
<value>third target</value>
</data>
</root>
```
For more information about the Resx format, see the [Microsoft documentation](https://docs.microsoft.com/en-us/dotnet/framework/resources/creating-resource-files-for-desktop-apps#resx-files).

### TsProj
TsProj is a file format for storing translation strings in a .tsproj file.\
It is a xml based format, intended to use with the Ashampoo Translation Studio,
with the following structure:

```xml
<?xml version="1.0" encoding="utf-8"?>
<project name="My Project" version="1.0" author="Author" mail="[email protected]" source_language="source_language"
target_language="target_language">
<component pluginguid="{F0D8F625-2EE3-4C84-96EC-BFBDD4946878}">
<translation id="first id">
<comment>first comment</comment>
<source>first source</source>
<target>first target</target>
</translation>
<translation id="second id">
<comment>second comment</comment>
<source>second source</source>
<target>second target</target>
</translation>
<translation id="third id">
<comment>third comment</comment>
<source>third source</source>
<target>third target</target>
</translation>
</component>
</project>
```



## License
This project is licensed under the MIT license.

## Contributing
Contributions are always welcome!\
Please read the [contribution guidelines](CONTRIBUTING.md) first.

## Code of Conduct
This project and everyone participating in it is governed by the [Code of Conduct](CODE_OF_CONDUCT.md).

0 comments on commit cf4649f

Please sign in to comment.