Debian Codegraph @

src/deprecated_units/castlelocalization_castlecore.inc

raw
1 {
2 Copyright 2018 Benedikt Magnus.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 { TODO:
17
18 This file should be removed, use TranslateProperties routine
19 to uniformly translate UI stuff in CGE now.
20 However, it's hard to fix it without breaking compatibility
21 (of translation files) because now, CastleLocalization only allows
22 a single string per component (while TranslateProperties allows
23 to expose e.g. 2 properties on a component, like TCastleEdit.Text
24 and TCastleEdit.Placeholder).
25 }
26
27 {$ifdef read_interface}
28
29 type
30 { A descendent of TCastleLabel that can be localised with CastleLocalization. }
31 TCastleLabelLocalizable = class (TCastleLabel, ICastleLocalization)
32 public
33 procedure OnUpdateLocalization(const ALocalizedText: String);
34 end;
35
36 { A descendent of TCastleButton that can be localised with CastleLocalization. }
37 TCastleButtonLocalizable = class (TCastleButton, ICastleLocalization)
38 public
39 procedure OnUpdateLocalization(const ALocalizedText: String);
40 end;
41
42 { A descendent of TCastleOnScreenMenuItem that can be localised with CastleLocalization. }
43 TCastleOnScreenMenuItemLocalizable = class (TCastleOnScreenMenuItem, ICastleLocalization)
44 public
45 procedure OnUpdateLocalization(const ALocalizedText: String);
46 end;
47
48 { A descendent of TCastleEdit that can be localised with CastleLocalization. }
49 TCastleEditLocalizable = class (TCastleEdit, ICastleLocalization)
50 private
51 FLastLocalizedText: String;
52 public
53 procedure OnUpdateLocalization(const ALocalizedText: String);
54 end;
55
56 {$endif read_interface}
57
58 {$ifdef read_implementation}
59
60 { TCastleLabelLocalizable ----------------------------------------------------- }
61
62 procedure TCastleLabelLocalizable.OnUpdateLocalization(const ALocalizedText: String);
63 begin
64 Caption := ALocalizedText;
65 end;
66
67 { TCastleButtonLocalizable ----------------------------------------------------- }
68
69 procedure TCastleButtonLocalizable.OnUpdateLocalization(const ALocalizedText: String);
70 begin
71 Caption := ALocalizedText;
72 end;
73
74 { TCastleOnScreenMenuItemLocalizable ----------------------------------------------------- }
75
76 procedure TCastleOnScreenMenuItemLocalizable.OnUpdateLocalization(const ALocalizedText: String);
77 begin
78 Caption := ALocalizedText;
79 end;
80
81 { TCastleEditLocalizable ----------------------------------------------------- }
82
83 procedure TCastleEditLocalizable.OnUpdateLocalization(const ALocalizedText: String);
84 begin
85 if Text = FLastLocalizedText then //Only localise if the text hasn't been changed manually.
86 begin
87 FLastLocalizedText := ALocalizedText;
88 Text := FLastLocalizedText;
89 end;
90 end;
91
92 {$endif read_implementation}