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

Using lg sh or ah with rest api doesn't translate title to hebrew #38

Open
roidayan opened this issue Oct 12, 2019 · 3 comments
Open

Using lg sh or ah with rest api doesn't translate title to hebrew #38

roidayan opened this issue Oct 12, 2019 · 3 comments

Comments

@roidayan
Copy link

roidayan commented Oct 12, 2019

When using lg=ah or lg=sh the title is not translated into hebrew.
When using lg=h its fine.

the issue is maybe from line 753 in local/share/perl/site_perl/Hebcal.pm
https://github.com/hebcal/dotcom/blob/master/local/share/perl/site_perl/Hebcal.pm
the check is only for "h"

    if ($lang eq "h" || $lang_european{$lang}) {
        my $xsubj = Hebcal::translate_event($evt, $lang);
        if ($xsubj && $xsubj ne $subj) {
            $item{title_orig} = $subj;
            $subj = $xsubj;
        }
    }

looking in translate_event() the check is also for "ah" and "sh"

    } elsif ($lang eq "h" || $lang eq "ah" || $lang eq "sh") {
        return $evt->{hebrew};
@mjradwin
Copy link
Member

mjradwin commented Oct 13, 2019 via email

@roidayan
Copy link
Author

right. just the hebrew key and title key sometimes little different.
since 'h' is documented in the rest api i thought to use it.
example for candle lighting and havdalah it adds the time already to the title.
i'll use lg=s and parse the time manually and use hebrew key.
thanks.

        [1] => Array
            (
                [title] => הדלקת נרות: 17:53
                [hebrew] => הדלקת נרות
                [title_orig] => Candle lighting
                [date] => 2019-10-13T17:53:00+03:00
                [category] => candles
            )
        [10] => Array
            (
                [title] => הבדלה - 50 דקות: 18:54
                [hebrew] => הבדלה - 50 דקות
                [title_orig] => Havdalah (50 min)
                [date] => 2019-10-19T18:54:00+03:00
                [category] => havdalah
            )

@roidayan roidayan reopened this Oct 13, 2019
@roidayan
Copy link
Author

roidayan commented Oct 13, 2019

I was rethinking. it should work. like fr should translate to france. options 'h', 'ah', 'sh' documented as supported in the rest api.

looks like the issue is just checking lang eq 'h' only, while the inner callback does check every option possible. I think maybe the first check is redundant and line 753 can be removed. calling translate_event() is doing the check and if nothing is needed returns undef which means title key wont be changed.

a user supposedly can send the lang according to "locale" like 'h' or 'fr' etc and always use key 'title'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants