From fc82964caf435bc5851f2fc548d95a5445511bef Mon Sep 17 00:00:00 2001 From: lobsam Date: Thu, 15 Feb 2024 13:09:26 +0530 Subject: [PATCH 1/2] hebrew to tibetan --- static/css/s2.css | 84 +++++++++--------- static/js/ContentText.jsx | 9 +- static/js/Misc.jsx | 8 +- static/js/ReaderApp.jsx | 2 +- static/js/ReaderPanel.jsx | 4 +- static/js/TextRange.jsx | 12 ++- .../VersionBlock/VersionBlockWithPreview.jsx | 2 +- static/js/VersionBlock/VersionInformation.jsx | 2 +- static/js/sefaria/boNumber.js | 86 +++++++++++++++++++ static/js/sefaria/sefaria.js | 2 +- 10 files changed, 149 insertions(+), 62 deletions(-) create mode 100644 static/js/sefaria/boNumber.js diff --git a/static/css/s2.css b/static/css/s2.css index 34ea421acb..add2090b7d 100644 --- a/static/css/s2.css +++ b/static/css/s2.css @@ -192,7 +192,7 @@ body, .en, .int-en { font-size: 122%; } .int-he { - direction: rtl; + direction: ltr; } .int-he.enInHe { direction: ltr; @@ -201,7 +201,7 @@ body, .en, .int-en { unicode-bidi: isolate; } .int-en.heInEn { - direction: rtl; + direction: ltr; } .btn, .btn-sm, .btn-xs { display: inline-block; @@ -400,7 +400,7 @@ body.hasBannerMessage #s2.headerOnly { height: 180px; } .interface-hebrew #bannerMessage { - direction: rtl; + direction: ltr; } #bannerMessageClose { position: absolute; @@ -473,14 +473,14 @@ input.noselect { -webkit-user-select: auto; /* Safari/Opera -- required for Safari to allow inputs to be accessible. See http://caniuse.com/#feat=user-select-none "Known Issues" for details TODO Check back to see if bug is fixed in future version */ } .interface-hebrew { - direction: rtl; + direction: ltr; } .interface-hebrew .int-en, .interface-english .int-he { display: none; } .interface-hebrew #panelWrapBox { - direction: rtl; + direction: ltr; } .interface-english #panelWrapBox, .readerApp.interface-english .readerPanel { @@ -729,7 +729,7 @@ div:has(#bannerMessage) + .readerApp.singlePanel .mobileNavMenu { padding-top: 12px; } .ui-autocomplete .ui-menu-item.hebrew-result a { - direction: rtl; + direction: ltr; } .ui-autocomplete .ui-menu-item.english-result a { direction: ltr; @@ -883,7 +883,7 @@ div:has(#bannerMessage) + .readerApp.singlePanel .mobileNavMenu { display: block; } .interface-hebrew .header .interfaceLinks .interfaceLinks-option.int-bi { - direction: rtl; + direction: ltr; } .interface-english .header .interfaceLinks .interfaceLinks-option.int-bi { direction: ltr; @@ -1154,7 +1154,7 @@ div.interfaceLinks-row a { line-height: 1.5; } .interface-hebrew .sefariaModalContent { - direction: rtl; + direction: ltr; } .sefariaModalContent a { color: white; @@ -1261,7 +1261,7 @@ div.interfaceLinks-row a { .interface-hebrew #defaultModal { text-align: right; - direction: rtl; + direction: ltr; } #defaultModalBody { @@ -1377,7 +1377,7 @@ div.interfaceLinks-row a { padding: 6px 12px; } .interface-hebrew .ui-autocomplete .ui-menu-item { - direction: rtl; + direction: ltr; text-align: right; } .ui-autocomplete .ui-menu-item img { @@ -1405,7 +1405,7 @@ div.interfaceLinks-row a { display: none; } .interface-hebrew .ui-autocomplete .ui-menu-item a { - direction: rtl; + direction: ltr; text-align: right; } #globalWarningMessage { @@ -1934,7 +1934,7 @@ div.interfaceLinks-row a { line-height: 60px; } .interface-hebrew .readerNavTop { - direction: rtl; + direction: ltr; } .readerNavTop .readerNavTopStart { display: flex; @@ -2022,7 +2022,7 @@ div.interfaceLinks-row a { .interface-hebrew .sidebarSearch .searchBox, .interface-hebrew .sidebarSearch .version, .interface-hebrew .sidebarSearch .result-title { - direction: rtl; + direction: ltr; } .sidebarSearch .searchBox { display: flex; @@ -2466,7 +2466,7 @@ h1 .languageToggle .he { margin-bottom: 40px; } .readerPanel.hebrew .navToggles { - direction: rtl; + direction: ltr; } .readerNavMenu .navToggles { flex-direction: row; @@ -3283,7 +3283,7 @@ display: none; align-items: start; } .interface-hebrew .textTableOfContents .structToggles{ - direction: rtl; + direction: ltr; } .interface-english .textTableOfContents .structToggles{ direction: ltr; @@ -3506,7 +3506,7 @@ display: none; } .english .noLangToggleInHebrew .textTableOfContents, .bilingual .noLangToggleInHebrew .textTableOfContents{ - direction: rtl; + direction: ltr; } .bookPage .button.allVersionsButton { color: #999; @@ -3843,7 +3843,7 @@ select { .modTools .modtoolsButton .he, .bookPage .content .versionDownloadButton .he { font-family: "Heebo", sans-serif; - direction: rtl; + direction: ltr; text-align: right; } .modTools a .modtoolsButton, @@ -4547,10 +4547,10 @@ body .ui-autocomplete.dictionary-toc-autocomplete .ui-menu-item a.ui-state-focus direction: ltr; } .interface-hebrew .readerPanel .readerNavMenu .tagsList .gridBox { - direction: rtl; + direction: ltr; } .tagsList .heOnly { - direction: rtl; + direction: ltr; } .tagsList .enOnly { direction: ltr; @@ -4678,7 +4678,7 @@ body .ui-autocomplete.dictionary-toc-autocomplete .ui-menu-item a.ui-state-focus text-decoration: none; } .interface-hebrew .trans-pref-header-container .trans-pref-reset { - direction: rtl; + direction: ltr; } .interface-hebrew .trans-pref-header-container .trans-pref-reset .smallText { padding-bottom: 2px; @@ -4867,7 +4867,7 @@ body .ui-autocomplete.dictionary-toc-autocomplete .ui-menu-item a.ui-state-focus font-size: 16px; } .hebrew .readerControls .readerTextToc { - direction: rtl; + direction: ltr; } .english .readerControls .readerTextToc { direction: ltr; @@ -4876,7 +4876,7 @@ body .ui-autocomplete.dictionary-toc-autocomplete .ui-menu-item a.ui-state-focus direction: ltr; } .interface-hebrew .bilingual .readerControls .readerTextToc { - direction: rtl; + direction: ltr; } .interface-hebrew .bilingual .readerControls .readerTextToc .readerTextTocBox.sheetBox, .interface-hebrew .english .readerControls .readerTextToc .readerTextTocBox.sheetBox { @@ -5459,7 +5459,7 @@ body .ui-autocomplete.dictionary-toc-autocomplete .ui-menu-item a.ui-state-focus } .segment.heOnly{ text-align: right; - direction: rtl; + direction: ltr; } .segment.enOnly{ text-align: left; @@ -5747,7 +5747,7 @@ But not to use a display block directive that might break continuous mode for ot height: 100%; } .interface-hebrew .connectionsPanelHeader { - direction: rtl; + direction: ltr; } .interface-english .connectionsPanelHeader { direction: ltr; @@ -5964,7 +5964,7 @@ But not to use a display block directive that might break continuous mode for ot font-family: "HebrewInEnglish Serif Font", "adobe-garamond-pro", "Crimson Text", Georgia, serif; } .hebrew .textList .recentFilterSet.filterSet { - direction: rtl; + direction: ltr; } .textList.singlePanel .connectionsHeader .topFilters{ overflow-x: scroll; @@ -6462,7 +6462,7 @@ But not to use a display block directive that might break continuous mode for ot } .webpageList .webpage.hebrew{ text-align: right; - direction: rtl; + direction: ltr; } .webpageList .webpage .icon { margin-right: 10px; @@ -6498,7 +6498,7 @@ But not to use a display block directive that might break continuous mode for ot } .interface-hebrew .webpageList .webpage .webpageMetadata { text-align: right; - direction: rtl; + direction: ltr; } .interface-english .webpageList .webpage .webpageMetadata { text-align: left; @@ -6775,13 +6775,13 @@ But not to use a display block directive that might break continuous mode for ot content: " "; } .topicList.topicsHe { - direction: rtl; + direction: ltr; } .topicList.topicsEn { direction: ltr; } .interface-hebrew .topicList.topicsEn { - direction: rtl; + direction: ltr; } .topicButton { @@ -7721,7 +7721,7 @@ a .button:hover { direction: ltr; } .readerPanel.hebrew .named-entity-wrapper { - direction: rtl; + direction: ltr; } .lexicon-results .named-entity-description { margin-top: 13px; @@ -7799,7 +7799,7 @@ a .button:hover { display: inline; } .lexicon-content .headword.he, .lexicon-content .definition-content.he { - direction: rtl; + direction: ltr; } .lexicon-content .headword.en, .lexicon-content .definition-content.en { direction: ltr; @@ -7920,7 +7920,7 @@ a .button:hover { direction: ltr; } .readerPanel .collectionsList .heCollections .gridBox { - direction: rtl; + direction: ltr; } .collectionListing { display: flex; @@ -8211,7 +8211,7 @@ body.interface-english .publishBox .react-tags__suggestions ul { cursor: auto; } .interface-hebrew .sheetMetaDataBox .authorStatement { - direction: rtl; + direction: ltr; } .editorSidebarToggle { position: fixed; @@ -9317,7 +9317,7 @@ body #keyboardInputMaster tbody tr td table tbody tr td.pressed{ display: flex; } .readerPanel.hebrew .aboutBox .aboutAuthor .aboutAuthorInner{ - direction: rtl; + direction: ltr; } .aboutBox .aboutAuthor .authorName{ margin-inline-start: 5px; @@ -9402,7 +9402,7 @@ body #keyboardInputMaster tbody tr td table tbody tr td.pressed{ color: #666666; } .interface-hebrew .versionsBox .versionLanguage { - direction: rtl; + direction: ltr; } .versionsBox div:not(:first-child) .versionLanguage { padding-top: 25px; @@ -9689,7 +9689,7 @@ span.purim-emoji img{ font-size: 16px; } .interface-hebrew .sheetContent .element-link .popup { - direction: rtl; + direction: ltr; } .sheetContent .element-link .popup input { @@ -10642,7 +10642,7 @@ cursor: pointer; left: 0; } .interface-hebrew .editorToggleHeader { - direction: rtl; + direction: ltr; } .editorToggleHeader .button { padding: 5px 8px; @@ -10663,7 +10663,7 @@ cursor: pointer; box-sizing: border-box; } .interface-hebrew .feedbackOverlay { - direction: rtl; + direction: ltr; } .feedbackOverlay .buttonContainer { margin-top: 50px; @@ -11311,7 +11311,7 @@ body .homeFeedWrapper .content { padding-inline-start: 20px; } .readerPanel.hebrew .savedHistoryList .colorBarBox{ - direction: rtl; + direction: ltr; } .interface-english .citationLine, .interface-english .learnMoreLink { @@ -11627,7 +11627,7 @@ body .homeFeedWrapper.userStats { font-size: 16px; } .editTextInfo #newIndex #heTitle { - direction: rtl; + direction: ltr; } .interface-english .editTextInfo .static label { text-align: left; @@ -11917,7 +11917,7 @@ body .homeFeedWrapper.userStats { .userStats .yourPopularSheetsBlock > div { padding: 10px 0; } -.userStats .chartLabel { +.userStats .chaltrabel { text-align: center; padding-top: 8px; } @@ -12377,7 +12377,7 @@ span.ref-link-color-3 {color: blue} border-radius: 6px; right: 0px; } -.beitMidrashUser .userDetailsMenu[dir="rtl"] { +.beitMidrashUser .userDetailsMenu[dir="ltr"] { position: absolute; background-color: black; box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); diff --git a/static/js/ContentText.jsx b/static/js/ContentText.jsx index 234979da76..d77f1e4a04 100644 --- a/static/js/ContentText.jsx +++ b/static/js/ContentText.jsx @@ -2,6 +2,7 @@ import React from "react"; import {useContentLang} from './Hooks'; import Sefaria from './sefaria/sefaria'; import ReactMarkdown from "react-markdown"; +import { hebrewToTibetan } from './sefaria/boNumber.js' const ContentText = (props) => { /* Renders content language throughout the site (content that comes from the database and is not interface language). @@ -78,12 +79,14 @@ const _filterContentTextByLang = ({text, html, markdown, overrideLanguage, defau } const ContentSpan = ({lang, content, isHTML, markdown}) => { + //pecha.org code + let boContent = hebrewToTibetan(content, lang ) return isHTML ? - + : markdown ? - {content} + {boContent} - : {content}; + : {boContent}; } export {ContentText, VersionContent}; diff --git a/static/js/Misc.jsx b/static/js/Misc.jsx index 03c9c1cdce..1d9de731e4 100644 --- a/static/js/Misc.jsx +++ b/static/js/Misc.jsx @@ -637,7 +637,7 @@ class DropdownOptionList extends Component { {option.name} - {option.heName} + {option.heName} ); @@ -1350,8 +1350,8 @@ class DisplaySettingsButton extends Component { if (Sefaria._siteSettings.TORAH_SPECIFIC) { icon = - Toggle Reader Menu Display Settings - Toggle Reader Menu Display Settings + Toggle Reader Menu Display Settings + ; } else { icon = Aa; @@ -2845,7 +2845,7 @@ const SheetTitle = (props) => ( contentEditable={props.editable} suppressContentEditableWarning={true} onBlur={props.editable ? props.blurCallback : null} - style={{"direction": Sefaria.hebrew.isHebrew(props.title.stripHtml()) ? "rtl" :"ltr"}} + style={{"direction": Sefaria.hebrew.isHebrew(props.title.stripHtml()) ? "ltr" :"ltr"}} > {props.title ? props.title.stripHtmlConvertLineBreaks() : ""} diff --git a/static/js/ReaderApp.jsx b/static/js/ReaderApp.jsx index 121bfc6826..e00f395b16 100644 --- a/static/js/ReaderApp.jsx +++ b/static/js/ReaderApp.jsx @@ -107,7 +107,7 @@ class ReaderApp extends Component { }).map(panel => this.makePanelState(panel)); const defaultVersions = Sefaria.util.clone(props.initialDefaultVersions) || {}; - const layoutOrientation = (props.interfaceLang == "hebrew") ? "rtl" : "ltr"; + const layoutOrientation = (props.interfaceLang == "hebrew") ? "ltr" : "ltr"; this.state = { panels: panels, diff --git a/static/js/ReaderPanel.jsx b/static/js/ReaderPanel.jsx index 5bca1cebd9..b3a03cb6e9 100644 --- a/static/js/ReaderPanel.jsx +++ b/static/js/ReaderPanel.jsx @@ -1508,8 +1508,8 @@ class ReaderDisplayOptionsMenu extends Component { render() { let languageOptions = [ {name: "english", content: "A", role: "radio", ariaLabel: "Show English Text" }, - {name: "bilingual", content: "Aא", role: "radio", ariaLabel: "Show English & Hebrew Text" }, - {name: "hebrew", content: "א", role: "radio", ariaLabel: "Show Hebrew Text" } + {name: "bilingual", content: "A", role: "radio", ariaLabel: "Show English & Hebrew Text" }, + {name: "hebrew", content: "", role: "radio", ariaLabel: "Show Hebrew Text" } ]; let languageToggle = this.showLangaugeToggle() ? ( diff --git a/static/js/VersionBlock/VersionInformation.jsx b/static/js/VersionBlock/VersionInformation.jsx index 6a48ed8ccf..c97d0eccb5 100644 --- a/static/js/VersionBlock/VersionInformation.jsx +++ b/static/js/VersionBlock/VersionInformation.jsx @@ -22,7 +22,7 @@ function VersionInformation({currentRef, version}) {
{`${Sefaria._("Digitization")}: `} - < /span> + {Sefaria._("Sefaria")} diff --git a/static/js/sefaria/boNumber.js b/static/js/sefaria/boNumber.js new file mode 100644 index 0000000000..d1aba92d6b --- /dev/null +++ b/static/js/sefaria/boNumber.js @@ -0,0 +1,86 @@ +// this code first convert hebrew number to english number and then convert english number to tibetan number +export function hebrewToTibetan(inputString, lang) { + //trim space from input string if lang is hebrew + let hebrewNumber = (lang === 'he') ? inputString.trim() : inputString; + let isHebNumber = isHebrewNumber(hebrewNumber) + //return if lang is not hebrew or input string is not hebrew number + if (lang !== 'he' || !isHebNumber) return hebrewNumber; + const hebrewDigits = { + 'א': 1, + 'ב': 2, + 'ג': 3, + 'ד': 4, + 'ה': 5, + 'ו': 6, + 'ז': 7, + 'ח': 8, + 'ט': 9, + 'י': 10, + 'כ': 20, + 'ל': 30, + 'מ': 40, + 'נ': 50, + 'ס': 60, + 'ע': 70, + 'פ': 80, + 'צ': 90, + 'ק': 100, + 'ר': 200, + 'ש': 300, + 'ת': 400 + }; + + let englishNumber = 0; + let prevDigitValue = 0; + + for (let i = 0; i < hebrewNumber.length; i++) { + const currentDigit = hebrewNumber[i]; + const currentDigitValue = hebrewDigits[currentDigit]; + + if (currentDigitValue) { + if (prevDigitValue && prevDigitValue < currentDigitValue) { + englishNumber = englishNumber - prevDigitValue + (currentDigitValue - prevDigitValue); + prevDigitValue = 0; + } else { + englishNumber += currentDigitValue; + prevDigitValue = currentDigitValue; + } + } + } + return englishToTibetan(englishNumber.toString()); +} + +function englishToTibetan(englishNumber) { + const englishDigits = { + '0': '༠', + '1': '༡', + '2': '༢', + '3': '༣', + '4': '༤', + '5': '༥', + '6': '༦', + '7': '༧', + '8': '༨', + '9': '༩' + }; + + const englishDigitsArray = englishNumber.split(''); + let tibetanEquivalent = ''; + + for (let i = 0; i < englishDigitsArray.length; i++) { + const digit = englishDigitsArray[i]; + const tibetanDigit = englishDigits[digit]; + + if (tibetanDigit) { + tibetanEquivalent += tibetanDigit; + } + } + + return tibetanEquivalent; +} + +function isHebrewNumber(text) { + const hebrewNumbers = /^[\u05D0-\u05EA\u05F0-\u05F4\u0591-\u05C7]+$/; // Regular expression to match Hebrew numerals + // Check if every character in the text is a Hebrew numeral + return hebrewNumbers.test(text); +} diff --git a/static/js/sefaria/sefaria.js b/static/js/sefaria/sefaria.js index 1767206f7a..e094d16a1a 100644 --- a/static/js/sefaria/sefaria.js +++ b/static/js/sefaria/sefaria.js @@ -560,7 +560,7 @@ Sefaria = extend(Sefaria, { "fa": {"name": "Persian", "nativeName": "فارسی", "showTranslations": 1, "title": "متون یهودی به زبان فارسی"}, "fi": {"name": "Finnish", "nativeName": "suomen kieli", "showTranslations": 1, "title": "Juutalaiset tekstit suomeksi"}, "fr": {"name": "French", "nativeName": "Français", "showTranslations": 1, "title": "Textes juifs en français"}, - "he": {"name": "Hebrew", "nativeName": "עברית", "showTranslations": 0, "title": "ספריה בעברית"}, + "he": {"name": "Tibetan", "nativeName": "עברית", "showTranslations": 0, "title": "ספריה בעברית"}, "it": {"name": "Italian", "nativeName": "Italiano", "showTranslations": 1, "title": "Testi ebraici in italiano"}, "lad": {"name": "Ladino", "nativeName": "Judeo-español", "showTranslations": 0}, "pl": {"name": "Polish", "nativeName": "Polski", "showTranslations": 1, "title": "Teksty żydowskie w języku polskim"}, From ac794d9142fac7d24ba7f7a2903ef5719ebec499 Mon Sep 17 00:00:00 2001 From: lobsam Date: Thu, 15 Feb 2024 13:49:22 +0530 Subject: [PATCH 2/2] edited language change icon --- static/img/aleph.svg | 1 - static/img/ka.svg | 39 +++++++++++++++++++++++++++++++++++++++ static/js/Misc.jsx | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) delete mode 100644 static/img/aleph.svg create mode 100644 static/img/ka.svg diff --git a/static/img/aleph.svg b/static/img/aleph.svg deleted file mode 100644 index 368f81645b..0000000000 --- a/static/img/aleph.svg +++ /dev/null @@ -1 +0,0 @@ -aleph \ No newline at end of file diff --git a/static/img/ka.svg b/static/img/ka.svg new file mode 100644 index 0000000000..b01748bbee --- /dev/null +++ b/static/img/ka.svg @@ -0,0 +1,39 @@ + + + + aleph + + diff --git a/static/js/Misc.jsx b/static/js/Misc.jsx index 1d9de731e4..d2edaf4da5 100644 --- a/static/js/Misc.jsx +++ b/static/js/Misc.jsx @@ -841,7 +841,7 @@ class LanguageToggleButton extends Component { render() { var url = this.props.url || ""; return ( - Hebrew Language Toggle Icon + Hebrew Language Toggle Icon English Language Toggle Icon ); }