Skip to content

matecat/subfiltering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matecat Subfiltering

Build Status Scrutinizer Code Quality Code Coverage

Subfiltering is a component used by Matecat and MyMemory) for string conversion from database to UI layer and viceversa.

How to use

There are two filters available (both are implementation of AbstractFilter):

  • MateCatFilter
  • MyMemoryFilter

Use getInstance method to instantiate these classes:

use Matecat\SubFiltering\MateCatFilter;

$filter = MateCatFilter::getInstance(new FeatureSet(), 'it-IT', 'en-EN', []);

The first argument MUST be concrete implementation of Matecat\SubFiltering\Contracts\FeatureSetInterface.

The other three arguments are optional:

  • $source (string) - The source language
  • $target (string) - The target language
  • $dataRefMap (array) - A map used for tag replacement (only for segments from Xliff 2.0). A full documentation for dataRef replacement is available here.

dataRef replacement

Basic Usage

Once AbstractFilter class is instantiated you can use several methods to convert strings from one layer to another one.

MateCatFilter methods

  • fromLayer0ToLayer2
  • fromLayer1ToLayer2
  • fromLayer2ToLayer1
  • fromLayer2ToLayer0
  • fromLayer0ToLayer1
  • fromLayer1ToLayer0
  • fromRawXliffToLayer0
  • fromLayer0ToRawXliff

MyMemoryFilter methods

  • fromLayer0ToLayer1
  • fromLayer1ToLayer0

Where Layer0 is the DB layer, Layer1 is the intermediate layer and Layer2 is the MateCat's UI layer.

Examples

In the tests folder there is an fully working example of a concrete implementation of FeatureSetInterface with a custom filter.

// tests/Mocks 
.
├── Features
│   ├── AirbnbFeature.php
│   └── BaseFeature.php
└── FeatureSet.php

Support

If you found an issue or had an idea please refer to this section.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details