Skip to content

Commit

Permalink
V:: v.0.4.0
Browse files Browse the repository at this point in the history
API to set language programmatically.
  • Loading branch information
RussCoder committed Aug 19, 2020
1 parent 156ef4c commit 20cb9aa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "DjVu.js Viewer",
"short_name": "DV",
"version": "0.3.6.1",
"version": "0.4.0.0",
"author": "RussCoder",
"homepage_url": "https://github.com/RussCoder/djvujs",
"description": "Opens links to .djvu files. Allows to open .djvu files from a local disk. Processes djvu <object> & <embed> tags.",
Expand Down
4 changes: 4 additions & 0 deletions viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# DjVu.js Viewer Changelog

## v.0.4.0 (19.08.2020)
- Multi-Language support.
- Russian and English languages.

## v.0.3.6 (27.07.2020)
- An ability to load a file by URL manually in the extension.
- An extension option to analyze http headers to detect djvu files.
Expand Down
17 changes: 13 additions & 4 deletions viewer/src/DjVuViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import EventEmitter from 'eventemitter3';
import Consts, { constant } from './constants/consts';
import { get } from './reducers';
import { ActionTypes } from './constants/index.js';
import dictionaries from './locales';

const Events = constant({
PAGE_NUMBER_CHANGED: null,
Expand All @@ -17,14 +18,22 @@ const Events = constant({

export default class DjVuViewer extends EventEmitter {

static VERSION = '0.3.6';
static VERSION = '0.4.0';

static Events = Events;

constructor() {
static getAvailableLanguages() {
return Object.keys(dictionaries);
};

constructor({ language = null } = {}) {
super();
this.store = configureStore(this.eventMiddleware);

if (language) {
this.configure({ language: language });
}

if (process.env.NODE_ENV === 'development') {
if (module.hot) {
module.hot.accept('./components/App', () => {
Expand Down Expand Up @@ -87,10 +96,10 @@ export default class DjVuViewer extends EventEmitter {
);
}

configure({ pageNumber, pageRotation, pageScale } = {}) {
configure({ pageNumber, pageRotation, pageScale, language } = {}) {
this.store.dispatch({
type: ActionTypes.CONFIGURE,
pageNumber, pageRotation, pageScale
pageNumber, pageRotation, pageScale, language
});

return this;
Expand Down
10 changes: 7 additions & 3 deletions viewer/src/sagas/rootSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,15 @@ class RootSaga {
yield put(Actions.pagesSizesAreGottenAction(pagesSizes));
}

* configure({ pageNumber, pageRotation, pageScale }) {
* configure({ pageNumber, pageRotation, pageScale, language }) {
if (pageNumber) yield put(Actions.setNewPageNumberAction(pageNumber, true));
if (pageRotation) yield put(Actions.setPageRotationAction(pageRotation));
if (pageScale) yield put(Actions.setUserScaleAction(pageScale));
if (language && (language in dictionaries)) yield put({
type: ActionTypes.UPDATE_OPTIONS,
payload: { locale: language },
notSave: true,
});
}

* createDocumentFromArrayBuffer({ arrayBuffer, fileName, config }) {
Expand Down Expand Up @@ -258,7 +263,6 @@ class RootSaga {
const shortCode = code.slice(0, 2);
if (shortCode in dictionaries) {
options.locale = shortCode;
console.log(options);
break;
}
}
Expand All @@ -269,7 +273,7 @@ class RootSaga {
type: ActionTypes.UPDATE_OPTIONS,
payload: options,
notSave: true,
})
});
}
} catch (e) { }
}
Expand Down

0 comments on commit 20cb9aa

Please sign in to comment.