issue-#88 support for localizable documentation

Merged to the master branch
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#88 support for localizable documentation

Post by Josef Templ »

A small fix seems to be needed in DevSearch.ThisText:
It ignores the 'source' parameter, which has been introduced in issue-#88.
Should the 'source' parameter be removed again or should it be used?
In other words: is searching in source code language dependent or not?
Since the compiler does not look up source files according to the selected language,
I think it does not give sense to do a language dependent search for sources.

So the fix would be to use the 'search' parameter instead of ignoring it.
Change the first line from

Code: Select all

	IF (Dialog.language # "") & (Dialog.language # "en") THEN
			v := Views.OldView(loc.This(Dialog.language), name)
		ELSE v := NIL
		END;
to

Code: Select all

	IF ~source & (Dialog.language # "") & (Dialog.language # "en") THEN
			v := Views.OldView(loc.This(Dialog.language), name)
		ELSE v := NIL
		END;


- Josef
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#88 support for localizable documentation

Post by Josef Templ »

There is even a more severe bug in DevSearch.
It still uses the CAP function for case insensitive search.
This works only for ASCII, not for Unicode.
It must use Strings.Upper().
However, this actually belongs to a different issue.

- Josef
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#88 support for localizable documentation

Post by Josef Templ »

please comment
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#88 support for localizable documentation

Post by Ivan Denisov »

Josef Templ wrote:is searching in source code language dependent or not?
Search in sources should not depend from language.
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#88 support for localizable documentation

Post by Zinn »

I wonder that you did it not in the same way as the original CPC version.
There I left the procedure ThisText unchanged and add the 4 lines of language test 2 times in the procedure Search.
This way minimized the change from BB 1.6
- Helmut

Code: Select all

	PROCEDURE ThisText (loc: Files.Locator; VAR name: Files.Name): TextModels.Model;
		VAR v: Views.View; m: Models.Model;
	BEGIN
		v := Views.OldView(loc, name);
		IF v # NIL THEN
			m := v.ThisModel();
			IF m # NIL THEN
				WITH m: TextModels.Model DO RETURN m ELSE END
			END
		END;
		RETURN NIL
	END ThisText;

Code: Select all

			w.ConnectTo(log); w.SetPos(0);
			IF source THEN loc := Files.dir.This("Mod"); path := "Mod"
			ELSE loc := Files.dir.This("Docu"); path := "Docu";
				IF (Dialog.language # "") & (Dialog.language # "en") THEN
					loc := loc.This(Dialog.language);
					path := path + "/" + Dialog.language
				END
			END;

Code: Select all

				loc := Files.dir.This(dirs.name); path := dirs.name + "/";
				IF source THEN loc := loc.This("Mod"); path := path + "Mod"
				ELSE loc := loc.This("Docu"); path := path +"Docu";
					IF (Dialog.language # "") & (Dialog.language # "en") THEN
						loc := loc.This(Dialog.language);
						path := path + "/" + Dialog.language
					END
				END;
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#88 support for localizable documentation

Post by Josef Templ »

Helmut, I think it was done in this way for keeping the changes of Search to a minimum.
Now we have only an additional parameter passed to ThisText when compared to BB1.6
Search is already a very long procedure and it is better to avoid any code
replication inside Search since this would make it even longer and more complicated.
ThisText, on the other hand, is still short and easy to comprehend and it avoids any code
replication.

- Josef
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#88 support for localizable documentation

Post by Josef Templ »

My proposal for the changes are in the branch issue-#88.
For the changes see http://redmine.blackboxframework.org/pr ... 2db74b3ae8.

It has been aligned with the coding style in StdApi, where the parameter named useLang is used for that purpose.

- Josef
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#88 support for localizable documentation

Post by Josef Templ »

can we proceed with this? I think yes.
User avatar
DGDanforth
Posts: 1061
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA
Contact:

Re: issue-#88 support for localizable documentation

Post by DGDanforth »

Josef Templ wrote:My proposal for the changes are in the branch issue-#88.
For the changes see http://redmine.blackboxframework.org/pr ... 2db74b3ae8.

It has been aligned with the coding style in StdApi, where the parameter named useLang is used for that purpose.

- Josef

Code: Select all

  PROCEDURE ThisText (loc: Files.Locator; VAR name: Files.Name; source: BOOLEAN): TextModels.Model;

  PROCEDURE ThisText (loc: Files.Locator; VAR name: Files.Name; useLang: BOOLEAN): TextModels.Model;

Which seems to replace "source" with "useLang" and yet later in the comparison "source" is still used (as "~source").
Its not clear to me what has or has not been replaced.
-Doug
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#88 support for localizable documentation

Post by Josef Templ »

'ThisText' is not concerned with the distinction between source or docu or whatever kind of file.
It only needs to know if it should look at a language subdirectory.
Therefore it uses a parameter named useLang in the same way as it is done in StdApi.

'Search' on the other hand is called for two kinds of files, for sources and for docu.
Therefore it has a parameter named source and if set it uses Mod otherwise it uses Docu.
This has not been changed and it doesn't give much sense to change that.

- Josef
Post Reply