Translatable Strings and if they are used
Posted: Fri Aug 07, 2009 2:37 pm
by ConvertFromOldNGs
by MichaelHill >> Mon, 4 Mar 2002 22:24:37 GMT
Morning All,
Just a quick query. I have a program what has been going over the last 6 years and has a heap (4000+) translatable strings. What I want to do is find out if the strings are used or not and if not then remove them. Does anyone know how (programmatically) to check whether these strings are used in the source or where I should start so I can do this.
Cheers
Michael Hill
Gallagher Group Ltd
Re: Translatable Strings and if they are used
Posted: Fri Aug 07, 2009 2:37 pm
by ConvertFromOldNGs
by cnwjhp1 >> Mon, 4 Mar 2002 23:29:05 GMT
Michael,
Below is a script I threw together (and it looks like it) yesterday to find a similar sort of thing. (In my case, properties with a certain naming convention that are not explicit inverses.) You'll need to start from a collection of translatable strings, and check if getMethodRefs returns a collection of size 0. Don't know if I'd attempt to delete them this way tho. Hope this helps.
Cheers,
John P
jhpUnusedMyGlobals();
vars
threshold,i,j,k,l:Integer;
s,t,u,v:String;
startClas,clas:Class;
classColl:ClassColl;
property:Property;
methodSet:MethodSet;begin
create classColl transient;
LINCOBJECT.allSubclassesInSubschemas(classColl);
// classColl.add(currentSchema.findClassInSubschema("R_Admr050")); // for an individual class
write CrLf&"Starting...";
create methodSet transient;
foreach clas in classColl do
// write clas.name;
foreach property in clas.getProperties where property.name[1:3]="myG" do
s:=(clas.name&"::"&property.name).padBlanks(40)&property.name; // write s;
// methodSet.clear;
// if property.name="myGlobal_Adm98" then property.inspect; endif;
// property.getMethodRefs(methodSet);
if not property.isKindOf(ExplicitInverseRef) then
write s;
i:=i+1;
endif;
endforeach;
endforeach;
write i;
write CrLf&"Finished";
epilog
delete classColl;
delete methodSet;
end;