Bug 12705 - News not possible for one sublanguage if two sublanguages are installed
Summary: News not possible for one sublanguage if two sublanguages are installed
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P4 normal (vote)
Assignee: Marc Véron
QA Contact: Testopia
URL:
Keywords:
: 7541 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-08-03 12:18 UTC by Marc Véron
Modified: 2015-12-03 22:02 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 12705 - News not possible for one sublanguage if two sublanguages are installed (3.24 KB, patch)
2014-08-03 17:35 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 12705 - News not possible for one sublanguage if two sublanguages are installed (1.33 KB, patch)
2014-08-09 07:06 UTC, Marc Véron
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 12705 - News not possible for one sublanguage if two sublanguages are installed (1.43 KB, patch)
2014-08-09 11:02 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[PASSED QA] Bug 12705 - News not possible for one sublanguage if two sublanguages are installed (1.62 KB, patch)
2014-08-17 22:27 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Véron 2014-08-03 12:18:35 UTC
To reproduce:

Install and enable (in systempreferences:I18N/L10N language) e.g.
Português
    Português (pt-PT) 
    Português (pt-BR) 
Deutsch
    Deutsch (de-CH) 
    Deutsch (de-DE)

Go to cgi-bin/koha/tools/koha-news.pl and try to create news.

The dropdown 'Display location' contains:
- All
- Librarian interface
- Slip
- OPAC (pt-BR)
- OPAC (en)
- OPAC (de-DE)

OPAC (de-CH) and OPAC (pt-PT) are missing. It is not possible to create news for them (even if you disable e.g. de-DE or pt-BR) in system preferences).
Comment 1 Marc Véron 2014-08-03 17:35:35 UTC Comment hidden (obsolete)
Comment 2 Bernardo Gonzalez Kriegel 2014-08-07 23:12:12 UTC
Marc, your patch works and has no errors, but I wonder if someone could see this as a regression because you can't put a news on a specific variant of a language.

You can't right now, but the problem is the strange structure returned by getTranslatedLanguages()

If you change this

foreach my $language ( @$tlangs ) {
   push @lang_list,
     {
       language => $language->{'rfc4646_subtag'},
       selected => ( $new_detail->{lang} eq $language->{'rfc4646_subtag'} ? 1 : 0 ),
     };
}

with this

foreach my $language ( @$tlangs ) {
  foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
    push @lang_list,
      {
        language => $sublanguage->{'rfc4646_subtag'},
        selected => ( $new_detail->{lang} eq $sublanguage->{'rfc4646_subtag'} ? 1 : 0 ),
      };
    }
  }
}

then the problem is solved.

Perhaps a new feature could be a multiple selection on target languages or interfaces for news display location.

Another feature could show here only 'active' languages, 
i.e. only push if ( $sublanguage->{'enabled'} )
Comment 3 Marc Véron 2014-08-07 23:43:56 UTC
Bernardo, thanks for the comment. 

I considered to change getTranslatedLanguages() but:
a) I could not really find out what to change...
b) I was afraid that changes could have side effects because the function is used at several places

Anyway, I think it is better to keep the behaviour as it was originally intended (News per language variants). At the moment the most important thing for me is to fix the bug, because I can not display de-CH news at the moment.

Regarding the new features:
----
Perhaps a new feature could be a multiple selection on target languages or interfaces for news display location.
MV: That would be nice for a follow up

----
Another feature could show here only 'active' languages, 
i.e. only push if ( $sublanguage->{'enabled'} )
MV: As far as I remember there was a discussion somewhere about this idea with following scenario: It could be possible that a library plans to introduce an additional language. They prepare some news in this language, but do not yet enable it.
Comment 4 Bernardo Gonzalez Kriegel 2014-08-08 00:26:37 UTC
(In reply to Marc Véron from comment #3)
> Regarding the new features:
> ----
> Perhaps a new feature could be a multiple selection on target languages or
> interfaces for news display location.
> MV: That would be nice for a follow up
> 

Yeah, will think about that

> Another feature could show here only 'active' languages, 
> i.e. only push if ( $sublanguage->{'enabled'} )
> MV: As far as I remember there was a discussion somewhere about this idea
> with following scenario: It could be possible that a library plans to
> introduce an additional language. They prepare some news in this language,
> but do not yet enable it.

Right, no changes there then :)
Comment 5 Marc Véron 2014-08-09 06:26:25 UTC
Comment on attachment 30518 [details] [review]
Bug 12705 -  News not possible for one sublanguage if two sublanguages are installed

New patch follows.
Comment 6 Marc Véron 2014-08-09 07:06:26 UTC Comment hidden (obsolete)
Comment 7 Bernardo Gonzalez Kriegel 2014-08-09 11:02:06 UTC Comment hidden (obsolete)
Comment 8 Mark Tompsett 2014-08-09 18:46:16 UTC
*** Bug 7541 has been marked as a duplicate of this bug. ***
Comment 9 Katrin Fischer 2014-08-17 22:27:49 UTC
Created attachment 30898 [details] [review]
[PASSED QA] Bug 12705 - News not possible for one sublanguage if two sublanguages are installed

To test:
- Install two language variants (e.g. de-DE and de-CH)
- Create OPAC news for each of them
- Verify that they are displayed in OPAC as appropriate

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Works Ok, no koha-qa errors

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works ok, all installed languages now show up in the pull downs
and display for the selected language in the OPAC.
Passes tests and QA script.
Comment 10 Tomás Cohen Arazi 2014-09-02 13:44:13 UTC
Patch pushed to master.

Thanks Marc!
Comment 11 Mason James 2015-02-25 10:39:35 UTC
(In reply to Tomás Cohen Arazi from comment #10)
> Patch pushed to master.
> 
> Thanks Marc!

Pushed to 3.16.x, patch will be in 3.16.8