Skip to content

Commit

Permalink
Add language support to the OCR manager (#7465)
Browse files Browse the repository at this point in the history
* add LanguageCodeMapper

* add ukrainian language to elastic search

* simplify languages support

* update languageSchema

* revert changes

* use legacy elastic mapping

* fix language code

* fix test case

* add other language to available languages array

* fix test errors

---------

Co-authored-by: Joan Gallego Girona <daneryl@gmail.com>
  • Loading branch information
2 people authored and RafaPolit committed Dec 11, 2024
1 parent fa937c4 commit 04d2aca
Show file tree
Hide file tree
Showing 7 changed files with 341 additions and 49 deletions.
4 changes: 2 additions & 2 deletions app/api/entities.v2/types/EntityInputDataSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { availableLanguagesISO6391 } from 'shared/languagesList';
import { ISO6391Codes } from 'shared/languagesList';

const linkSchema = {
type: 'object',
Expand Down Expand Up @@ -78,7 +78,7 @@ export const entityInputDataSchema = {
properties: {
_id: { type: 'string' },
sharedId: { type: 'string', minLength: 1 },
language: { enum: availableLanguagesISO6391 },
language: { enum: ISO6391Codes },
title: { type: 'string', minLength: 1 },
template: { type: 'string' },
metadata: metadataSchema,
Expand Down
8 changes: 5 additions & 3 deletions app/react/Attachments/components/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect, ConnectedProps } from 'react-redux';
import { bindActionCreators, Dispatch } from 'redux';
import { Control } from 'react-redux-form';
import { withContext } from 'app/componentWrappers';
import { Translate, t } from 'app/I18N';
import { t, Translate } from 'app/I18N';
import { Icon } from 'UI';
import { APIURL } from 'app/config.js';
import { ClientBlobFile } from 'app/istore';
Expand All @@ -12,7 +12,7 @@ import { wrapDispatch } from 'app/Multireducer';
import { TocGeneratedLabel } from 'app/ToggledFeatures/tocGeneration';
import { NeedAuthorization } from 'app/Auth';
import { LocalForm } from 'app/Forms/Form';
import { language as transformLanguage, availableLanguages } from 'shared/languagesList';
import { availableLanguages, getLanguageSchema } from 'shared/languagesList';
import { isBlobFile } from 'shared/tsUtils';
import { EntitySchema } from 'shared/types/entityType';
import { FileType } from 'shared/types/fileType';
Expand Down Expand Up @@ -100,11 +100,12 @@ class File extends Component<FileOwnProps, FileState> {
renderReady() {
const { language, filename = '' } = this.props.file;
const { readonly } = this.props;

return (
<div>
<div>
<span className="badge">
<Translate>{language ? transformLanguage(language) || '' : ''}</Translate>
<Translate>{language ? getLanguageSchema(language)?.label || '' : ''}</Translate>
</span>
<TocGeneratedLabel file={this.props.file}>
<Translate>ML TOC</Translate>
Expand Down Expand Up @@ -196,6 +197,7 @@ class File extends Component<FileOwnProps, FileState> {
{language.localized_label} ({language.label})
</option>
))}

<option value="other">{t('System', 'other', 'other', false)}</option>
</Control.select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/react/Attachments/components/specs/File.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('file', () => {
expect(title).toBe('Human_name_1.pdf');

const language = component.find('.badge').find(Translate).props().children;
expect(language).toBe('english');
expect(language).toBe('English');
});

describe('read only', () => {
Expand Down
Loading

0 comments on commit 04d2aca

Please sign in to comment.