Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mobile): ✨ Add transliteration in grammar #2210

Merged
merged 5 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/controllers/words.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

const COLLECTIONS = require('../constants/collections.js')
const { capitalizeFirstLetter, shuffleArray, convertToLowerCase, getAllWordsFromTexts } = require('../services/texts')
const { timeAgo } = require('../services/utils')
const { ObjectId } = require('mongodb')
const { removeAnythingBetweenBrackets } = require('../services/utils')
const { removeAnythingBetweenBrackets, timeAgo } = require('../services/utils')

async function getWordId(request, reply) {
try {
Expand Down
3 changes: 2 additions & 1 deletion api/services/texts.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function getWordsPairedWithId(word) {
return { arabicWord, englishWord }
}

export const removeAnythingBetweenBrackets = (text) => {
const removeAnythingBetweenBrackets = (text) => {
// remove anything between brackets
let updatedText = text.replaceAll(/\[.*?]/g, '')

Expand Down Expand Up @@ -299,6 +299,7 @@ module.exports = {
getAllWordsFromTexts,
batchGenerateAudio,
generateGuidForSentencesAndWords,
removeAnythingBetweenBrackets,
addGuidToArray,
addGuidToInnerArray,
produceVocabularyCollection,
Expand Down
Binary file modified mobile/.yarn/install-state.gz
Binary file not shown.
Empty file.
2 changes: 1 addition & 1 deletion mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"homepage": "https://openarabic.io",
"repository": "https://github.com/edenmind/OpenArabic",
"version": "1444.12.318",
"version": "1444.12.323",
"authors": [
"Yunus Andreasson <yunus@edenmind.com> (https://github.com/YunusAndreasson)"
],
Expand Down
1 change: 0 additions & 1 deletion mobile/redux/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ const wordsReducer = createReducer(initialStateWords, (builder) => {
})
})


const textReducer = createReducer(initialStateText, (builder) => {
builder
.addCase(actions.SET_TEXT, (state, action) => {
Expand Down
6 changes: 5 additions & 1 deletion mobile/screens/text-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { StyleSheet, ScrollView } from 'react-native'
import React from 'react'
import PropTypes from 'prop-types'
import { formatGrammar } from '../services/ui-services.js'
import { transliterateArabicToEnglish } from '../services/utility-service.js'
import { useSharedStyles } from '../styles/common.js'

export default function TextGrammar({ route }) {
Expand All @@ -17,6 +18,8 @@ export default function TextGrammar({ route }) {
}
})

const transliteratedArabic = transliterateArabicToEnglish(arabic)

return (
<ScrollView style={style.scrollView}>
<Text
Expand All @@ -40,8 +43,9 @@ export default function TextGrammar({ route }) {
paddingBottom: 50
}}
>
{english}
{english} - {transliteratedArabic}
</Text>

{formatGrammar(grammar, sharedStyle)}
<Divider style={{ marginBottom: 50, opacity: 0 }} />
</ScrollView>
Expand Down
32 changes: 32 additions & 0 deletions mobile/screens/text-grammar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { it } from '@jest/globals'
import TextGrammar from './text-grammar.js'
import React from 'react'
import { Provider } from 'react-redux'
import { store } from '../redux/store.js'
import { NavigationContainer } from '@react-navigation/native'
import { render } from '@testing-library/react-native'

describe('TextGrammar', () => {
it('renders the required properties', () => {
const props = {
route: {
params: {
grammar: 'some grammar',
arabic: 'some arabic text',
english: 'some english text'
}
}
}

const { getByText } = render(
<Provider store={store}>
<NavigationContainer>
<TextGrammar {...props} />
</NavigationContainer>
</Provider>
)

expect(getByText('some grammar')).toBeDefined()
expect(getByText('some arabic text')).toBeDefined()
})
})
2 changes: 1 addition & 1 deletion mobile/screens/text-list-card-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function TextListCardGrammar({ text, navigation, setShouldReload
})
}}
>
View Grammar Lesson
View Lesson
</Button>
</Card.Actions>
</Card>
Expand Down
30 changes: 30 additions & 0 deletions mobile/screens/text-list-card-grammar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import { render } from '@testing-library/react-native'
import { Provider } from 'react-redux'
import { store } from '../redux/store.js'
import { NavigationContainer } from '@react-navigation/native'
import TextListCardGrammar from './text-list-card-grammar.js'

describe('TextListCardGrammar', () => {
it('renders the required properties', () => {
const props = {
navigation: {},
setShouldReload: jest.fn(),
text: {
english: 'some english text',
arabic: 'some arabic text'
}
}

const { getByText } = render(
<Provider store={store}>
<NavigationContainer>
<TextListCardGrammar {...props} />
</NavigationContainer>
</Provider>
)

expect(getByText('some english text')).toBeDefined()
expect(getByText('some arabic text')).toBeDefined()
})
})
18 changes: 0 additions & 18 deletions web/src/__snapshots__/index.test.js.snap

This file was deleted.

21 changes: 0 additions & 21 deletions web/src/index.test.js

This file was deleted.

Loading