Add language to control - orbeon

Is there a way to add to easily add text for a not included language to a control that is included in Orbeon, ie what having to recompile Orbeon / contribute and wait for new release? In particular, adding "Please Select:" in another language for select components.
I have seen http://doc.orbeon.com/contributors/localizing-orbeon-forms.html, but was hoping there was a way such as adding it to a property in properties-local that could speed up the process.

The localizations for a XBL controls are embedded in the XBL file itself. So no unfortunately there is no way to override these via properties at this point.
For adding a new language to Form Runner, you also need to add that language to the Form Runner resources.xml file. Adding resources via properties can only patch existing Form Runner resources, but not create new ones. That is a limitation which, in theory, could be lifted, with some work.

Related

Adding declarations and definitions in the IDE for runtime components

I'm dealing with creating a number of components at runtime and setting their methods. Is there a way to add the declartion and definition stubs for a component without adding it to the form and clicking the corresponding event on the events tab?
I know I can add a component temporarily to create the stub, or sometimes the help files list the declaration. But there are a lot of features in the IDE that I have not found or used.
Replying to comments:
What I do currently is workable I just wondered if there was a shortcut I was missing. To reiterate as some did not understand; I am using component AwesomeComponent in my application. I only need to create instances of AwesomeComponent at runtime, so it is not on my form (or perhaps is non-visual). AmesomeComponent has an event DoSomething. That event has a number of parameters. In order to assign AmesomeComponent.OnDoSOmething at runtime, I need to code the event, but I don't have direct access to the procedure stub, I have to find it somewhere in documentation or create it on a dummy form to cut and paste it. I didn't know if there was an IDE feature that was smart enough to say "Ok, I recognize this name (AwesomeComponent.OnDoSOmething) as an event and create a stub for it. It must do essentially the same thing when double-clicking on the Events tab in the IDE.

Linking different forms in DELPHI within the same project

I am currently designing a database interface in DELPHI 2010, and I have designed several form interfaces, all encapsulated in one Delphi project structure.
I began designing a particular interface form first, and, as a result, an irrelevant form first appears when I run the .exe file, whereas I want a menu form to appear when the program is loaded. My questions are:
How can I get my menu form to open first when and .exe of my compiled project is run?
What function do I need to use to program navigation buttons on this menu to open new forms up?
What function should I use on the "Exit" buttons each of my forms to close the forms down individually, without closing the whole program?
I have good knowledge in Pascal, but I am new to programming object orientated solutions in this platform.
You should determine if you forms would be auto-created or created on demand.
You should also decide which form would be main one.
The corner question would be if you can have several open forms of the same class, for example if you made "File Viewer" form there may be sense to have several of them open for different files.
For auto-created forms:
1.1 Open project source (.dpr file, Project/View Source menu) or open Project options in Forms section. Set MenuForm the 1st (topmost) one in creation list.
1.2 Check that all other forms have their .visible property false
2: Depending on the logic of your program you should use Form1.Show or Form1.ShowModal
3: Self.Close or Self.Hide or Self.Visible := false. Better 1st: http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.Close
If u use OnClose event of those forms - ensure you did not changed default caHide action for closing
For manually lifetime controlled forms:
1: Open project source (.dpr file, Project/View Source menu) or open Project options in Forms section. Set MenuForm the only one created.
2.1. some-temporary-variable := TFormClass.Create(Application);
2.2. Then you tweak some properties of some-temporary-variable like filename to open or some data source or whatever.
2.3. Then you do some-temporary-variable.Show or some-temporary-variable.ShowModal.
Beware: using ShowModal may freeze your application, in cases like TFormClass.Create(SomeAnotherForm), use Application for parent.
3: Self.Release http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.Release
or Self.Close and specify caFree action in OnClose event - http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.OnClose

Code templates - unit name clash between Delphi versions

Different Delphi versions (in my case 2007, XE and XE2) seem to use the same code-template repository, such as ..\Documents\RAD Studio\code_templates. Since XE2 uses namespaced units, this causes problems when one have to use a unit name in a template.
For instance I have a template when I write winbeep which completes to windows.Beep(300, 100); and selects and stops on frequency etc.. This does not compile on XE2 unless I remove the Winapi. part of the Windows unit in the uses clause (or of course add the prefix manually). I have to have the unit name because otherwise SysUtils.Beep gets referred.
I couldn't find an option entry or a registry key or an environment variable specifying the place of the templates. It is not even related to BDSUSERDIR, in fact I don't even have a directory in my computer having the path of BDSUSERDIR (which is ..\Documents\RAD Studio\9.0). Is this my oversight and in fact there's an option to relocate code templates? If not, is it possible to make the IDE use unit aliases in uses clause for new forms?
edit:
Here it is stated that (emphasis by me) "Templates that you create (and templates provided by third party add-ins) are saved by default in the \My Documents\RAD Studio\code templates\ directory." That would imply there should be way to save them in a non-default place. But the article does not mention how.
You can put your templates in "Delphi installation folder"\ObjRepos\en\Code_Templates to make them visible only on one Delphi version.
Edit
As Sertac points out in the comments, Template libraries are related to project templates, not code templates. Leaving this answer in place because it may help people looking for ways to structure / share / split their project template repositories.
In Delphi XE2 you have a "Template libraries" option under the "Tools" menu. When you open that, you get this dialog:
The "Add" button allows you to add a folder, the "Properties" button allows you to view and manage the contents of that repository.
So it would seem to me that you can simply copy the template library, change it XE2 specific stuff, and then point XE2 to its own repository. Or you could do that only for the templates that require specific XE2 unit handling.

Creating resource only DLL with translated form resources

I have a large application which i want to migrate to Arabic. I have defined the strings that we show to the user under the resourcestring keyword.
I am using the External Translation manager provided with Delphi 6. However, I am not very much comfortable using the tool. I want to create a resource only dll with all the translated strings like how the Delphi ETM does, and then switch between languages at run-time at the click of a button.
I was able to link the resourcestrings to the Dll, but how about form's captions and hints and the component properties? I am loading the Dll at runtime depending on the language, but the form properties are not reflecting as they were not available in the Dll.
Any pointers in the right direction ???
Thanks
Rahul W
What the Delphi localization tool and runtime support do is to redirect resource loading - including forms - from the executable to the DLL. Forms, their components and controls (non default properties) are stored as resources into the executable (as long as you don't create them fully at runtime - but then you would have to set their properties one by one).
Thereby if you want to work alike the standard translation tool you have to work the same way. What the DLL Resource Wizard does is to extract all project .dfm (and those you add manually) and resourcestrings to a copy that can be localized. When an app is started the form loading code checks from where the .dfm should be loaded. You should override this code to load your resources.
Be aware that changes language at runtime may need a different approach, because loading a whole form from resources may "reset" it to the creation state. On the other hand, compared to approaches like gettext, it allows to localize far more than the form text, including images, colors, and to adapt control sizes to the new string easily. IMHO gettext is good for simple needs, but when localization becomes a complex task and you may need to localize for a very different "culture", more powerful tools are needed.

How To Subclass A Form in Delphi? Best Practices?

I've got a base form in Delphi 2007 that I'd like to reuse in another project, adding some other buttons and such.
I'm familiar with subclassing a non-GUI object, but it is possible to subclass a Form in the same fashion? Can you make changes to the subclass Form in design mode?
How do you go about doing this and what are some things to look out for?
As idursun said (he was a little quicker than me):
Add the base form to your new project.
Then choose "File\New\More..."
Form the "Delphi-Projects" branch select "Inheritable Elements", find your base form and click "OK".
(The actual names of the menu items may vary since I am using a german version of Delphi 2009)
You can then make changes to your new or your base form.
If I do so I make sure to have both forms open in the IDE since sometimes it seems Delphi doesn't get all the changes if I don't.
You should add your base form to your new project and in the new form window there should be an Inherit tab where you can select a base form for the new form.

Resources